C語言學生信息管理系統實驗報告_第1頁
C語言學生信息管理系統實驗報告_第2頁
C語言學生信息管理系統實驗報告_第3頁
已閱讀5頁,還剩12頁未讀, 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、C語言課程設計學生信息管理系統姓名洪偉生院系計算機學院日期2015年7月5日目錄第一章設計要求第二章算法分析1. 理論依據主要實現方法2.1整體流程圖2.2函數功能和函數之間的調用關系第三章代碼(源代碼)第四章分析說明第五章總結第一章、設計要求1、利用所學的知識、理論和實際結合,利用資源,采用模塊化的結構,使用模仿修改自主設計相結合的方法,鍛煉學生綜合分析解決實際問題的編程能力;2、通過C語言各個函數功能來實現對學生信息的管理,學生信息包括學生,學號,各科成績;管理方式包括對學生信息的錄入,保存,排序,查找、修改、刪除等功能。第二章、算法分析1、程序理論依據通過C語言的程序設計基礎的掌握,對學

2、生成績管理系統進行編寫程序。首先,通過鏈表這一數據結構來對學生的信息進行錄入以及操作,在其過程中,通過各個功能語句以及選擇結構,循環結構等方式的結合來達到所要實現的程序功能。最后通過對C語言中對文件的操作,對已有學生成績的讀取和新建學生成績的錄入保存。2、主要實現方法2.1整體流程圖學生信息管退出返回主菜單理系統進入學學學學學學生生生生生生信信信信信信息息息息息息錄瀏查修增刪入覽找改加除2.2、函數功能和函數之間的調用關系2.2.1、函數功能:voidMenu_1();/主菜單二級菜單voidMenu_2();/voidswap(structstudent*phead,structstuden

3、t*pback);表節點互換/鏈voidSave(structstudent*head);/盤寫入磁voidSearch(structstudent*head);/生信息查找學voidRead(structstudent*head);/生信息顯示學voidSort(structstudent*head);/點排序鏈表節structstudent*Create();/錄入學生信息手動structstudent*Readpoint();/磁盤文件寫入structstudent*Modify(structstudent*head);/體成員修改鏈表結構structstudent*Add(struct

4、student*head);/點插入鏈表節structstudent*Delete(structstudent*head);/鏈表節點刪除2.2.2、函數之間的調用關系:通過switch語句進行指令選擇:case1:學生信息錄入調用函數Create()、Save()、Menu_1()、Menu_2()case2:學生信息瀏覽調用函數Readpoint()、Sort()、Read()、Save()、Menu_1()、Menu_2()case3:學生信息查找調用函數Search()、Readpoint()、Menu_1()、Menu_2()case4:學生信息修改調用函數Modify()、Read

5、point()、Save()、Menu_1()、Menu_2()case5:學生信息增加調用函數Add()、Readpoint()、Save()、Menu_1()、Menu_2()case6:學生信息刪除調用函數Delete()、Readpoint()Save()、Menu_1()、Menu_2()case0:返回主菜單調用函數Menu_1()第三章、代碼(源代碼)/*學生信息管理系統*/#include<stdio.h>#include<stdlib.h>#include<string.h>structstudent/定義結構體intnum;charnam

6、e24;charsex5;intChinese;intMath;intEnglish;structstudent*next;voidswap(structstudent*phead,structstudent*pback);/鏈表節點互換voidSave(structstudent*head);/寫入磁盤voidSearch(structstudent*head);/查找學生信息voidRead(structstudent*head);/顯示學生信息voidSort(structstudent*head);/鏈表節點排序structstudent*Readpoint();/磁盤文件寫入存str

7、uctstudent*Create();/學生信息手動錄入structstudent*Modify(structstudent*head);/鏈表結構體成員修改structstudent*Add(structstudent*head);/鏈表節點插入structstudent*Delete(structstudent*head);/鏈表主菜單二級菜單節點刪除;voidMenu_1();/voidMenu_2();/intmain(void)(Menu_1();return0;voidMenu_1()(intnum;printf("tttt學生信息管理系統ttttn");pr

8、intf("ttt1:進入學生信息管理n");/主菜單printf("ttt0:退出學生信息管理n");printf("請您輸入指令:");scanf("%d”,&num);switch(num)(case1:Menu_2();break;您已退出default:printf("學生信息管理系統n");break;/*/voidMenu_2()structstudent*head;intnum;printf("ttt歡迎進入n");printf("n");p

9、rintf("ttt1:學生信息錄入n");printf(-ttt2:學生信息瀏覽n");printf("ttt3:學生信息查找n");printf("ttt4:學生信息修改n");/二級菜單printf("ttt5:學生信息增加n");printf(-ttt6:學生信息刪除n");printf("ttt0:返回主菜單n");printf("n");printf("請您輸入指令:");scanf("%d",&

10、num);switch(num)case1:head=Create();Save(head);printf("n");printf("ttt1:返回主菜單n");/手動錄入學生數據printf("ttt2:返回二級菜單n");printf("n");printf("請您輸入指令:");scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無效,返

11、回二級菜單!n");Menu_2();break;break;case2:(head=Readpoint();/寫入鏈表,返回頭指針Sort(head);printf(-ttt以學號升序排列n");Read(head);/鏈表數據寫入文件Save(head);printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級菜單n");printf("n");printf("請您輸入指令:");scanf("%d",&a

12、mp;num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無效,返回二級菜單!n");Menu_2();break;break;case3:(head=Readpoint();Search(head);/查找學生信息printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級菜單n");printf("n");printf("請您輸入指令:"

13、);scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:printf(-輸入無效,返回二級菜單!n");Menu_2();break;break;case4:head=Readpoint();Modify(head);/修改結構體成員并保存到文件Save(head);printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級菜單n");printf(&

14、quot;n");printf("請您輸入指令:");scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:printf(-輸入無效,返回二級菜單!n");Menu_2();break;break;case5:(head=Readpoint();增加學生信Add(head);息并保存到文件Save(head);printf("n");printf("ttt1:返回主菜單n");print

15、f("ttt2:返回二級菜單n");printf("n");printf("請您輸入指令:");scanf("%d”,&num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf("輸入無效,返回二級菜單!n");Menu_2();break;break;case6:(head=Readpoint();head=Delete(head);/刪除學生信息并保存到文件Save(head);printf("

16、;n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級菜單n");printf("n");printf("請您輸入指令:");scanf("%d",&num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無效,返回二級菜單!n");Menu_2();break;break;case0:Menu_1();break;default:(p

17、rintf("請重新輸入n");Menu_2();break;/*-*/structstudent*Create()/學生信息手動錄入(structstudent*head,*p,*q;intn;p=q=(structstudent*)malloc(sizeof(structstudent);printf(-請輸入學生的、學號、性別、語文成績、高等數學成績、英語成績:n");scanf("%s",q->name);scanf("%d%s%d%d%d",&q->num,&q->sex,&

18、;q->Chinese,&q->Math,&q->English);n=0;head=NULL;while(q->num!=0)(n=n+1;if(n=1)head=q;elsep->next=q;p=q;q=(structstudent*)malloc(sizeof(structstudent);scanf("%s",q->name);scanf("%d%s%d%d%d",&q->num,q->sex,&q->Chinese,&q->Math,&

19、q->English);p->next=NULL;printf(-學生信息錄入成功!n");returnhead;/*-*/structstudent*Readpoint()/學生信息寫入存,便于操作FILE*fp1;structstudent*head,*p,*q;intn;if(fp1=fopen("E:test.txt","rb")=NULL)printf("openfileerror!n");exit(0);p=q=(structstudent*)malloc(sizeof(structstudent);

20、fscanf(fp1,"%s%d%s%d%d%d",q->name,&q->num,q->sex,&q->Chinese,&q->Math,&q->English);n=0;head=NULL;while(!feof(fp1)n=n+1;if(n=1)head=q;elsep->next=q;p=q;q=(structstudent*)malloc(sizeof(structstudent);fscanf(fp1,"%s%d%s%d%d%d",&q->name,&am

21、p;q->num,&q->sex,&q->Chinese,&q->Math,&q->English);p->next=NULL;fclose(fp1);returnhead;/*-*/voidSwap(structstudent*phead,structstudent*pback)/鏈表元素數據交換structstudent*temp=(structstudent*)malloc(sizeof(structstudent);strcpy(temp->name,phead->name);temp->num=ph

22、ead->num;strcpy(temp->sex,phead->sex);temp->Chinese=phead->Chinese;temp->Math=phead->Math;temp->English=phead->English;strcpy(phead->name,pback->name);phead->num=pback->num;strcpy(phead->sex,pback->sex);phead->Chinese=pback->Chinese;phead->Math=p

23、back->Math;phead->English=pback->English;strcpy(pback->name,temp->name);pback->num=temp->num;strcpy(pback->sex,temp->sex);pback->Chinese=temp->Chinese;pback->Math=temp->Math;pback->English=temp->English;free(temp);/*-*/voidSort(structstudent*head)/學號排序(st

24、ructstudent*phead=(structstudent*)malloc(sizeof(structstudent);structstudent*pback=(structstudent*)malloc(sizeof(structstudent);phead=head;while(phead)(intNum=phead->num;pback=phead->next;while(pback)(if(Num>pback->num)(Swap(phead,pback);Num=phead->num;pback=pback->next;phead=phead

25、->next;/*-*/voidRead(structstudent*head)/學生信息讀取(structstudent*p;p=head;printf("n");printf(-學生的、學號、性別、語文成績、高等數學成績、英語成績:n");while(p!=NULL)(printf("%st%dt%st%dt%dtt%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;printf("n");

26、/*-*/voidSave(structstudent*head)/學生信息保存到文件structstudent*p;FILE*fp;if(fp=fopen("E:test.txt","wb")=NULL)printf("openfileerror!n");exit(0);p=head;while(p!=NULL)fprintf(fp,"%s%d%s%d%d%d",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);fprin

27、tf(fp,"%s","rn");p=p->next;fclose(fp);/*-*/voidSearch(structstudent*head)/學生信息查找intn;structstudent*p;charname24;intnum;charsex5;intChinese;intMath;intEnglish;printf("您想以何種方式進行查找:n");printf("1;n");printf("2:學號n");printf("3:性另叭n");printf(&

28、quot;4:語文成績n");printf("5:數學成績n");printf("6:英語成績n");printf("0:返回二級菜單n");scanf("%d",&n);switch(n)case1:printf(-請輸入:");/按查找scanf("%s",name);p=head;while(strcmp(name,p->name)!=0&&p->next!=NULL)p=p->next;if(strcmp(name,p->

29、;name)=0)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無此人!n");break;case2:printf(-請輸入學號:");/按學號查找scanf("%d",&num);p=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num=p->num)p

30、rintf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無此人!n");break;case3:(printf(-請輸入性別:");/按性別查找scanf("%s",sex);p=head;while(p!=NULL)(if(strcmp(sex,p->sex)=0)printf("%s%d%s%d%d%dn",p->name,p->

31、num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;case4:(printf("請輸入語文成績:");/按語文成績查找scanf("%d",&Chinese);p=head;while(p!=NULL)(if(Chinese=p->Chinese)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->Englis

32、h);p=p->next;break;case5:(printf("請輸入高等數學成績:");/按高等數學成績查找scanf("%d",&Math);p=head;while(p!=NULL)(if(Math=p->Math)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;case6:(printf("請輸入英語成績:"

33、);/按英語成績查找scanf("%d",&English);p=head;while(p!=NULL)(if(English=p->English)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;default:(printf(-指令錯誤返回二級菜單!n");Menu_2();break;/*-*/structstudent*Modify(structs

34、tudent*head)(intn;structstudent*p;charname24;intnum;printf("您想以何種方式進行修改:n");printf("1;n");printf("2:學號n");printf("0:返回二級菜單n");scanf("%d",&n);switch(n)(case1:(printf(-請輸入:");/按查找后修改信息scanf("%s",name);p=head;while(strcmp(name,p->n

35、ame)!=0&&p->next!=NULL)p=p->next;if(strcmp(name,p->name)=0)scanf("%s%d%s%d%d%d”,p->name,&p->num,p->sex,&p->Chinese,&p->Math,&p->English);printf("修改后:n");printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p-&

36、gt;Math,p->English);elseprintf("查無此人!n");break;case2:printf("請輸入學號:");/按學號查找后修改信息scanf("%d",&num);p=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num=p->num)scanf("%s%d%s%d%d%d",p->name,&p->num,p->sex,&p->Chi

37、nese,&p->Math,&p->English);printf("修改后:n");printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無此人!n");break;default:printf("指令錯誤,返回二級菜單!n");Menu_2();break;returnhead;structstudent*Add(struct

38、student*head)增加學生信息structstudent*p,*q;/為增加的學生分配存structstudent*add=(structstudent*)malloc(sizeof(structstudent);scanf("%s%d%s%d%d%d”,add->name,&add->num,add->sex,&add->Chinese,&add->Math,&add->English);q=head;if(head=NULL)head=add;/空表插入add->next=NULL;elsewhil

39、e(add->num>q->num)&&(q->next!=NULL)/指向下個節點p=q;q=q->next;if(add->num<=q->num)/插至U首節點if(head=q)head=add;elsep->next=add;/插到中間節點add->next=q;elseq->next=add;/插至U尾節點add->next=NULL;returnhead;structstudent*Delete(structstudent*head)/刪除學生信息intn;structstudent*p,*q;charname24;intnum;printf("您想以何種方式進行刪除:n");printf("1;n");printf("2:學號n");printf("0:返回二級菜單n");scanf("%d",&n);switch(n)case1:printf(-請輸入:");/按查找并刪除scanf("%s",name);p=head;while(strcmp(name,p->name)!=0&&am

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論