




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、頭文件Stud_mgr_system.h內(nèi)容如下:#ifndef STUD_MGR_SYSTEM_H#define STUD_MGR_SYSTEM_H#include<stdio.h>#include<stdlib.h>#include<string.h>#include<malloc.h>struct stud_mgr_sysint num;char name8;char phone12;char addr12;struct stud_mgr_sys *front;struct stud_mgr_sys *back;typedef struct
2、 stud_mgr_sys student;typedef student *DoubleLink;void printlist(DoubleLink L);DoubleLink addnode(DoubleLink L);DoubleLink deletenode(DoubleLink L);DoubleLink findinfo(DoubleLink L, int num);DoubleLink modifyinfo(DoubleLink L);DoubleLink creatdoublelink();void menu();void secrecy();DoubleLink read_f
3、ile(DoubleLink L);void save_file(DoubleLink L);#endif源文件opt_sys_api.c內(nèi)容如下:#include"stud_mgr_system.h"void print_err(char *p)perror("p");exit(1); void printlist(DoubleLink L) DoubleLink tmp; tmp = L;printf("n*n");while(tmp != NULL)printf("tThe student number: %dn&qu
4、ot;, tmp->num);printf("tThe student name: %sn", tmp->name);printf("tThe student phone: %sn", tmp->phone);printf("tThe student addr: %sn", tmp->addr);printf("n");tmp=tmp->front;printf("n*n");getchar(); DoubleLink creatdoublelink()Double
5、Link head;DoubleLink new_node, before;int count, i;head = (DoubleLink)malloc(sizeof(student);if(!head)print_err("Fail to malloc head");head->front = NULL;before = head->front;printf("Input number you want to create =>");scanf("%d", &count);for(i = 1; i <
6、= count; i+)new_node = (DoubleLink)malloc(sizeof(student);if(!new_node)print_err("Fail to malloc new_node");printf(" %d, The Number =>", i);scanf("%d", &new_node->num);printf("%d, The Name =>", i);scanf("%s", new_node->name);printf(&q
7、uot;%d, The Phone =>", i);scanf("%s", new_node->phone);printf("%d, The Addr =>", i);scanf("%s", new_node->addr);printf("n");new_node->front = NULL;if(head->front = NULL)head->front = new_node;before = head->front;before->back =
8、head;elsebefore->front = new_node;new_node->back = before;before = new_node;printf("Success to createnn");getchar();system("clear");return head->front;DoubleLink addnode(DoubleLink L)DoubleLink addnew, end;end = L;addnew = (DoubleLink)malloc(sizeof(student);if(!addnew)pr
9、int_err("Fail to malloc addnew");printf("Insert num =>");scanf("%d", &addnew->num);printf("Insert name =>");scanf("%s", addnew->name);printf("Insert phone =>");scanf("%s", addnew->phone);printf("Insert a
10、ddr =>");scanf("%s", addnew->addr);addnew->front = NULL;if(L = NULL)L = addnew;elsewhile(end->front != NULL)end = end->front;end->front = addnew;addnew->back = end;printf("nnInsert OKnn");return L;DoubleLink deletenode(DoubleLink L)DoubleLink ptr, tail;t
11、ail = L;while(tail->front != NULL)tail = tail->front;int delnum;printf("Please input student number you want delete =>");scanf("%d", &delnum);if(findinfo(L, delnum) = NULL)printf("nNo Information n");exit(1);printf("n=The information you delete=nn"
12、;);ptr = findinfo(L, delnum);printf("n=nn");printf("ttDelete Oknn");getchar();if(ptr = L)return L->front;else if(tail = ptr)tail->back->front = NULL;elseptr->back->front = ptr->front;ptr->front->back = ptr->back;return L;DoubleLink findinfo(DoubleLink L
13、, int findnum)int i = 1;DoubleLink ptr;ptr = L;if(L = NULL)printf("No informationn");exit(1);while(ptr != NULL)if(ptr->num = findnum)printf("nAt: %d nn", i);printf("n=nn");printf("tThe student number: %dn", ptr->num);printf("tThe student name: %sn&q
14、uot;, ptr->name);printf("tThe student phone: %sn", ptr->phone);printf("tThe student addr: %sn", ptr->addr);printf("nn=nn");getchar();return ptr;elseptr = ptr->front;i+;return ptr;DoubleLink modifyinfo(DoubleLink L)DoubleLink modptr;int modnum;printf("Pl
15、ease input student number you want modify =>");scanf("%d", &modnum);modptr = findinfo(L, modnum);if(modptr = NULL)printf("nnCan not find informationnn");else printf("Input New Number =>"); scanf("%d", &modptr->num); printf("Input New
16、 Name =>"); scanf("%s", modptr->name); printf("Input New Phone =>"); scanf("%s", modptr->phone); printf("Input New Addr =>"); scanf("%s", modptr->addr);printf("nnSuccess to Modifynn");return L;void menu()printf("
17、nn");printf("t=Student INFO System=nn");printf("t* MENU *n");printf("t* * *n");printf("t* 1.Create * 2.Display *n");printf("t* 3.search * 4.Add *n");printf("t* 5.Delete * 6.Modify *n");printf("t* 7.Exit * *n");printf("t*
18、 * *n");printf("t*n");void secrecy()char initsec10 = "123456"char inputsec10;int i, j = 0;printf("nInput:");for(i = 3; i >= 1; -i)scanf("%s", &inputsec);if(strcmp(initsec, inputsec) != 0)printf("nnYou have only %d timesn", i - 1);+j;getch
19、ar();system("clear");elsebreak;if(j = 3)printf("n");getchar();exit(1);system("clear");getchar();Main函數(shù)的內(nèi)容如下:#include"stud_mgr_system.h"int main(void)char opt;DoubleLink head = NULL;DoubleLink findnode = NULL;int findnum;secrecy();while(1)menu();printf("n&
20、quot;);printf("tEnter Your Choice: bb");scanf("%c", &opt);if(opt = 'n' | opt = '0')printf("ttt");printf("nnnCan not enter space keynn");else if(opt > '8' | opt < '1')printf("nnnInput errorn ");getchar();syste
21、m("clear");switch(opt)case '1':head = creatdoublelink();break;case '2':system("clear");printlist(head);getchar();system("clear");break;case '3':system("clear");printf("Please input number you want find =>");scanf("%d", &findnum);findnode = findinfo(head, findnum);if(!findnode)printf("nn
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 建筑企業(yè)技術(shù)支持崗位職責(zé)
- 歷史教師中考輔導(dǎo)教學(xué)計劃
- 金蝶財務(wù)軟件財務(wù)會計操作流程
- 電子商務(wù)公司各崗位職責(zé)
- 節(jié)假日保安服務(wù)安全保證措施
- 幼兒園教師課程改革守初心心得體會
- 六年級法治教育實踐計劃
- 酒店殘疾人殘障設(shè)備借用流程
- 2025年護理部護理資源整合計劃
- 以學(xué)案為翼展中學(xué)語文教學(xué)新程:理論、實踐與展望
- 信息安全培訓(xùn)《釣魚郵件防范技巧》
- 2025至2030中國燙印箔行業(yè)發(fā)展趨勢分析與未來投資戰(zhàn)略咨詢研究報告
- 部編版高一語文必修上冊教案計劃
- 臨時工請假管理制度
- 小學(xué)用電安全課件
- 體育老師招聘試題及答案
- 自然生態(tài)探險之旅行業(yè)跨境出海項目商業(yè)計劃書
- 2025年北京市高考英語試卷真題(含答案解析)
- 西藏自治區(qū)拉薩市達孜區(qū)孜縣2025年七下英語期中質(zhì)量檢測模擬試題含答案
- 2025年中國浮萍項目投資可行性研究報告
- 商洛學(xué)院《大學(xué)學(xué)術(shù)綜合英語》2023-2024學(xué)年第二學(xué)期期末試卷
評論
0/150
提交評論