這是第二週老師給的乙個小專案要求實現基本通訊錄功能,有資料的增刪改查,包含插入時間的能力。
標頭檔案
#include
#include
#include
//system功能呼叫
#include
//使用本地系統api獲取插入時間
#include
基本儲存結構體
typedef
struct infoa;
typedef
struct lnodelnode,
*linklist;
鍊錶資料初始化
用前插法插入資料
int
initlist
(linklist &l)
intlistinsert
(linklist &l,string name,string adress,string birthday,string date,string number)
本地windowsapi呼叫插入時間
systemtime sys;
getlocaltime
(&sys )
;string y =
doubletostring
(sys.wyear)
;string m =
doubletostring
(sys.wmonth)
;string d =
doubletostring
(sys.wday)
;string ymd = y+
"-"+m+
"-"+d;
因為獲取的是乙個double值,您得對其時間強制型別轉換
string doubletostring
(double num)
資料查詢功能
linklist searchelemchar
(linklist l,
int i,string e)
else}if
(l =
null)}
else
if(i ==2)
else}if
(l =
null)}
else
if(i ==3)
else}if
(l =
null)}
else
if(i ==4)
else}if
(l =
null)}
else
if(i ==5)
else}if
(l =
null)}
}
//樂公第二週專案 實現基本通訊錄儲存結構
//基礎鍊錶儲存資料
#include
#include
#include
//system功能呼叫
#include
//使用本地系統api獲取插入時間
#include
#define error 0
#define ok 1
using
namespace std;
typedef
int elemtype;
/*定義表元素的型別*/
//結構體檔案
typedef
struct infoa;
typedef
struct lnodelnode,
*linklist;
intinitlist
(linklist &l)
intlistinsert
(linklist &l,string name,string adress,string birthday,string date,string number)
//查詢元素 (難題需要解決)
linklist searchelemchar
(linklist l,
int i,string e)
else}if
(l =
null)}
else
if(i ==2)
else}if
(l =
null)}
else
if(i ==3)
else}if
(l =
null)}
else
if(i ==4)
else}if
(l =
null)}
else
if(i ==5)
else}if
(l =
null)}
} linklist searchelembefore
(linklist l,string e)
else}if
(l =
null)}
intshowmenu()
string doubletostring
(double num)
void
foreachelem
(linklist l)
else
cout<<
"\n";}
//system("pause");
}int
serachsamename
(linklist l,string name)
return1;
}int
main()
else
else
else}}
system
("pause");
system
("cls");
}else
if(i==2)
else
if(i==3)
case2:
else
break;}
case3:
case4:
default
:cout <<
"序號輸入錯誤,請重新輸入!"
system
("pause");
system
("cls");
}else
if(i==4)
else
break;}
case2:
else
break;}
case3:
else
break;}
case4:
else
break
;break;}
default
:cout <<
"序號輸入錯誤,請重新輸入!"
<}system
("pause");
system
("cls");
}else
if(i==5)
else
system
("pause");
system
("cls");
}else
if(i==6)
else
}return0;
}
本人不太擅長**優化,寫的可能比較長,如有錯誤歡迎各位指正! C 通訊錄設計 鍊錶實現
1新增學生資訊 2刪除學生資訊 3顯示學生資訊 4查詢學生資訊 5學生資訊排序 6清空螢幕資訊 7清空文件資訊 8退出管理系統 上 include include include include 讀寫檔案的標頭檔案 using namespace std struct elementtype str...
鍊錶通訊錄
include include include define password 208140119 define name max 20 define gender max 10 define str max 20 define tel max 20 鍊錶結構 struct address type...
鍊錶通訊錄
include include include include include struct addressbook typedef struct addressbook addressbook typedef struct addressbook link int main menu void a...