




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、頭文件Stud_mgr_system.h內容如下:#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內容如下:#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函數的內容如下:#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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年注會考試內容概述試題及答案
- 行政管理師考試的重要信息來源及試題及答案
- 2024年項目管理模擬測試試題及答案
- 2025年國際金融理財師考試資產保全與增值試題及答案
- 2024年微生物檢測的法規解讀試題及答案
- 2025年國際金融理財師考試職業現狀試題及答案
- 惠州酒店亮化施工方案
- 2024項目管理執行效果試題及答案
- 微生物檢驗技術人員的職業發展方向試題及答案
- 整合資料2025年國際金融理財師試題及答案
- (二模)2025年深圳市高三年級第二次調研考試歷史試卷(含標準答案)
- 一年級信息技術下冊 在網上交流信息教學設計 清華版
- 廣西《疼痛綜合評估規范》(材料)
- 廣東省2024-2025學年佛山市普通高中教學質量檢測政治試卷及答案(二)高三試卷(佛山二模)
- 11.1 杠桿 課件 2024-2025學年教科版物理八年級下學期
- 搶救工作制度課件
- LOGO更換普通夾板作業課件
- 2025年415全民國家安全教育日主題班會課件
- 美容師考試與法律法規相關知識及試題答案
- 山東省東營市東營區勝利第一初級中學2024-2025學年九年級下學期一模英語試卷(含答案無聽力原文及音頻)
- 臨床決策支持系統在路徑優化中的實踐案例
評論
0/150
提交評論