freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

c課程設(shè)計電話簿管理-資料下載頁

2024-11-13 06:56本頁面

【導(dǎo)讀】利用文本文件存儲電話薄數(shù)據(jù),具有添加、刪除、顯示和查詢聯(lián)系人號碼的功能。將電話薄數(shù)據(jù)和相應(yīng)的函數(shù)封裝在類中,改寫程序使之結(jié)構(gòu)化。增加記錄修改功能,能選擇修改用戶的姓名、電話。增加錄入時間的顯示及存儲。資料均在屏幕上顯示。類封裝成類是首先遇到的問題,我根據(jù)課程設(shè)計書上的提示,通過看書和與同學(xué)討論,最后比較清楚地明白了類的封裝方法。數(shù)都定義為公有成員,這樣可以方便類外的函數(shù)使用成員數(shù)據(jù)。只要求姓相同,全名查找要求姓和名全部相同??吹皆闯绦?,立馬被其擁有的函數(shù)的數(shù)量震撼了。是,看著它們由零散的函數(shù)變?yōu)檎R的類,就如同看到C語言向C++語言進化。而在C++里面,我尚且不知如何操作。最后通過互聯(lián)網(wǎng),才算學(xué)會在C++中調(diào)用時間單元。通過這次C++的課程設(shè)計,我的知識得到了鞏固,同時也學(xué)到了很多新知識。cout<<"\t\t學(xué)號:0710202020姓名:曹哲"<<endl<<endl;

  

【正文】 節(jié)點前的那 個節(jié)點成為新的鏈尾 current_ptr = head_ptr。 // 使 current_ptr 指向鏈首 } // 從鏈表中刪除節(jié)點 void friend_node::delete_from_middle_of_list(friend_node *previous_ptr) { // 摘下被刪除節(jié)點 previous_ptrnext = current_ptrnext。 delete current_ptr。 // 釋放被刪除節(jié)點占用的內(nèi)存 current_ptr = head_ptr。 // 使 current_ptr 指向鏈首 } // 釋放被鏈表占用的內(nèi)存 void friend_node::delete_list() { friend_node *temp_ptr。 // 定義一指針用來作臨時存儲 current_ptr = head_ptr。 // 使 current_ptr 指向鏈首 do // 遍歷鏈表 { temp_ptr = current_ptrnext。 // 使臨時指針指向被刪除節(jié)點的 next delete current_ptr。 // 刪除 current node 指針指向的節(jié)點 . current_ptr = temp_ptr。 // 再使 current_ptr 指向被刪除節(jié)點的 next 節(jié)點 } while(temp_ptr != NULL)。 } //修改記錄 void friend_node::modify_record(void) { int n。 char last_name1[20]。 char first_name1[15]。 char phone_num1[12]。 search_by_name()。//此時 current_ptr 指向欲修改的節(jié)點 if(current_ptr) { cout你想修改當前記錄的哪一項 ?。 cout\ :。 cout\ :。 cout\ :\n。 cinn。 switch(n) { case 1: cout請輸入新的姓 :。 cinlast_name1。 (20,39。\n39。)。 strcpy(current_ptrlast_name, last_name1)。 break。 case 2: cout請輸入新的名 :。 cinfirst_name1。 (15,39。\n39。)。 strcpy(current_ptrfirst_name, first_name1)。 break。 case 3: cout請輸入新的電話號碼 :。 cinphone_num1。 (12,39。\n39。)。 strcpy(current_ptrphone_num, phone_num1)。 break。 default: cout請重新選擇 !。 break。 }。 cout修改成功 !\n。 coutcurrent_ptrlast_name39。 39。current_ptrfirst_name endl。 coutcurrent_ptrphone_numendl。 getch()。 } else cout請重新輸入! \n。 system(cls)。 } istreamamp。 operator(istreamamp。 is,friend_nodeamp。 CTR)// { is。 is。 is。 is。 is。 is。 is。 is。 return is。 } // 寫入鏈表數(shù)據(jù)到文件 void friend_node::write_list_to_file() { ofstream outfile。 // 輸出文件指針 (由 ofstream 生成對象 outfile) (,ios::out)。 // 打開文件用于輸出數(shù)據(jù) if (outfile) // 若打開文件時未出錯 { // 即可將數(shù)據(jù)寫入文件 current_ptr = head_ptr。 // 使 current_ptr 指向鏈首 if(head_ptr != NULL) // 若鏈表不為空,開始向文件寫入數(shù)據(jù) { do // 遍歷鏈表 { // 向文件寫入節(jié)點數(shù)據(jù) outfile current_ptrlast_name endl。 outfile current_ptrfirst_name endl。 outfile current_ptrphone_num endl。 outfilenYearendl。 outfilenMonthendl。 outfilenDayendl。 outfilenHourendl。 outfilenMinuteendl。 current_ptr = current_ptrnext。 // 使 current_ptr 指向下一個節(jié)點 } while(current_ptr != NULL)。 // 循環(huán)直至鏈表尾 } // “文件結(jié)束”的標識將被寫入文件尾從而在讀取文件時方便知道已到達鏈表尾 ()。 // 關(guān)閉文件 } else // 若打開文件時出錯,顯示出錯信息 { cout 打開文件出錯 !\n。 } } // 從文件中讀取鏈表數(shù)據(jù) void friend_node::load_list_from_file() // 從數(shù)據(jù)文件 中讀取數(shù)據(jù)重建鏈表處理函數(shù) { friend_node *new_rec_ptr。 ifstream infile。 // 輸入文件指針 int end_loop = 0。 (,ios::in)。 // 打開文件用于輸入 if (infile) // 若打開文件時未出錯 { // 從文件時讀入數(shù)據(jù) do { new_rec_ptr = new friend_node。 // 為節(jié)點分配內(nèi)存 if(new_rec_ptr != NULL) // 檢查分配時是否出錯 { // 從文件中得到 next last name (new_rec_ptrlast_name,20)。 (20,39。\n39。)。 // 若文件未讀取完,繼續(xù)取得其他數(shù)據(jù) if((strcmp(new_rec_ptrlast_name, ) != 0) amp。amp。 (strcmp(new_rec_ptrlast_name, END OF FILE) != 0)) { (new_rec_ptrfirst_name, 15)。 (20,39。\n39。)。 (new_rec_ptrphone_num, 15)。 (20,39。\n39。)。 insert_node(new_rec_ptr)。 } else // 若文件讀取結(jié)束,刪除最近生成的節(jié)點 { // 并設(shè)置終止循環(huán)的標記 delete new_rec_ptr。 end_loop = 1。 } } else // 若分配內(nèi)存時出錯顯示出錯提示 { // 設(shè)置終止循環(huán)的標記 cout 警 告 : 內(nèi)存出錯 . 從磁盤讀取文件失敗 .\n。 end_loop = 1。 } } while(end_loop == 0)。 // 循環(huán)至 end_loop 標記為真 . ()。 // 關(guān)閉文件 } else // 若打開文件出錯,顯示出錯信息 { cout 沒有可用的數(shù)據(jù)存在,鏈表為空 .\n。 } } void main(void) { friend_node record。 ()。
點擊復(fù)制文檔內(nèi)容
高考資料相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1