c語言程序的設計_學生成績管理系統方案_第1頁
c語言程序的設計_學生成績管理系統方案_第2頁
c語言程序的設計_學生成績管理系統方案_第3頁
c語言程序的設計_學生成績管理系統方案_第4頁
已閱讀5頁,還剩20頁未讀 繼續免費閱讀

下載本文檔

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

文檔簡介

1、.實驗題目 : 學生成績管理系統一、實驗目的1. 熟悉 c 語言的編譯連接和運行過程。2. 掌握 c 語言的數據類型,熟悉整型、實型、字符型變量的定義方式及如何給它們賦值。3. 掌握 if 語句及 switch 語句的運用方法及嵌套應用方法。4. 掌握實現循環結構的三種語句 while 、 do-while. 、for 的使用。5. 掌握函數的定義方法和調用方法。6. 能夠采用模塊化思想調試程序。二實驗內容1. 編寫程序并進行調試運行。2. 輸入學生資料 , 并保存于文件。每個學生包含信息如:姓名、學號、性別、物理成績、數學成績、英語成績、計算機成績。3. 對已存入的學生信息進行更新操作 ,

2、包括更新學生信息信息、 刪除某個學生信息和修改學生信息。4. 通過按學生姓名的方式查詢學生信息。5. 輸入某學生各門成績進行統計。6 對學生物理成績排序。7. 最后輸出學生信息,供需要時打印。二、 需求分析1. 該程序可用于對學生的基本信息的存儲、更新、查詢、輸出、統計、排序等操作。2. 其中更新功能包括:添加信息、刪除信息、修改信息、可根據需要添加一個或多個學生 信息 , 也可對個別學生信息進行適當的刪除或修改。以便隨時更新學生信息。3. 程序中設計的查詢功能可根據需要從若干數據中查詢某信息,四、概要設計1、方案設計對系統進行分析,給出結構圖分析:系統要求實現許多的功能, 因此遵循結構化程序

3、設計思想來進行本系統的設計自頂向下、 逐步細化,將系統設計任務分解出許多子功能模塊進行設計結構圖如下:.下載可編輯 .學生成績管顯輸插查更統成物數英計保輸示入入看新計績理學語算存出數數數數數成排成成成機數數據據據據據績序績績績成據據績更刪修物數英計物新除改理學語算理數數數總總總機成據據據分分分平績和和和均排平平平分序.下載可編輯 .五功能模塊的說明1輸入初始學生信息:其中包括學生姓名,學號,性別,物理數學 英語 計算機成績 等相關信息;可用函數 cin(stu *p1) 來實現此操作。2查詢模塊:可用 stu *lookdata(stu *p1)來實現。找到就輸出此學生全部信息包括學生物理 數

4、學 英語 計算機的成績 。3插入模塊:可用 insert() 來實現。其中通過學號的大小比較的,并且以此來排序。4輸出學生的信息及成績:通過學生的姓名來查看學生的語文數學 英語 計算機的有關成績,同時也可以分別通過paverage() maverage() eaverage()comaverage() 來輸出物理 數學 英語 計算機等成績的平均分最高分 最低分。5退出系統:可以用一個函數來實現, 首先將信息保存在文件中, 釋放動態創建的內存空間,再退出次程序。流程圖如下六 調試情況及運行結果1、對自己設計進行評價,指出合理和不足之處,提出改進的方案。此次實踐課編寫的是一個應用程序, 相對于以前

5、我們見到的程序, 它要大得多,于是就按課本上的例子編了超市管理系統, 先把界面弄好然后再添加各模塊,而且各模塊也出現了不少問題, 在同學們和老師的幫助下,我很有耐心的一次又一次的進行修改, 最后運行的結果基本上達到了預期的目的。可結果還不是太理想。由于時間很短, 在選題報告中設想到的好多功能都沒有實現。 已有的那些功能雖已能基本上滿足管理者和消費者的需要, 但如果還有更多的功能程序就會更加完美。如:進入系統時沒有設制密碼,保護性不夠強;在輸入商品號時沒有出錯提示,如果商品號輸入負值2、在設計過程中的感受。本次 C 語言的實習課讓我對 C 語言的學習又有了更深入的了解,也讓我更深刻地領悟到了 “

6、實踐出真理” 這個道理,在上機實踐過程中學到的知識遠遠超過了在課堂上十幾周學到的, 學校組織的這次實習讓我們這些實踐知識匱乏的大學生增添了許多社會經驗, 為我們將來走上工作崗位其了不小的鋪墊作用。本次實習中遇到了很多以前沒有遇到過的問題, 也曾想過要放棄, 但看到那些同學都在那認真的寫程序, 給了我繼續的信心。 在同學的幫助下, 我順利的結束了本次實習, 讓我知道原來憑借自己努力取得的成功會讓自己這么欣慰,也讓我知道了友誼和團結的重要性。七參考文獻C 語言程序設計王曙燕曹錳科學出版社八。附錄:.下載可編輯 .#include <stdio.h>#include <stddef

7、.h>#include <stddef.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define MAX 10int sum=10;typedef struct student/*定義結構體 */char nameMAX;/*姓名 */int num;/*學號 */char sexMAX;/*性別 */float physic;/*語文 */float mathematic;/*數學 */float english;/*英語 */float computer;/*計算

8、機 */struct student *next;/*結構體指針 */stu;stu *head;/* 讀取信息 */int read_message() FILE *fp; stu *p; int i=0;if(fp=fopen("student_manage.txt","rb")=NULL) printf("nn*暫時還沒有任何信息,輸入密碼進入主菜單選擇基本信息錄入!*n");return 0;while(feof(fp)!=1) fread(head,sizeof(stu),1,fp); if(p->num=0) bre

9、ak;else i+;fclose(fp);return(i);.下載可編輯 ./*顯示或打印函數*/void print()printf("ttt Score Manage Systemn");/*成績管理系統 */printf("ttt成績管理系統 n");printf("<1>EnterRecord :輸入數據n");/*輸入數據 */printf("<2>Display :顯示或打印n");/*顯示 */printf("<3>find:查找數據n");

10、/*訪問數據 */printf("<4>Renew_message:更新模塊n");/*更新模塊 */printf("<5>Save:保存數據n");printf("<6>sort_physic:成績排名n");/*物理成績排名 */printf("<7>Count:數據統計n");/*數據統計 */printf("<8>Physic Average:物理平均成績n");/*物理平均成績 */printf("<9>

11、Math Average:數學平均成績n");/*數學平均成績 */printf("<10>English Average:英語平均成績n");/*英語平均成績 */printf("<11>Computer Average:計算機平均成績n");/*計算機平均成績 */printf("<12>Quit:退出tn");/*退出 */*輸入相關數據函數*/void cin(stu *p1)printf("n Enter name:n");scanf("%s&quo

12、t;,&p1->name);.下載可編輯 .printf("Enter num:n");scanf("%d",&p1->num);printf("Enter sex:n");scanf("%s",&p1->sex);printf("Enter scoren");printf("Enter physic:n");scanf("%f",&p1->physic);printf("Enter mat

13、hematic:n");scanf("%f",&p1->mathematic);printf("Enter english:n");scanf("%f",&p1->english);printf("Enter computer:n");scanf("%f",&p1->computer);/*其他數據是否輸入函數*/stu *cindata() stu *p1,*p2; int i=1; char ch; p1=(stu*)malloc(size

14、of(stu); head=p1;while(i) cin(p1);printf("Do you want to continue?Yes or no:n"); fflush(stdin);ch=getchar();if(ch='n'|ch='N') i=0;p1->next=NULL;else p2=p1; p1=(stu*)malloc(sizeof(stu); p2->next=p1;return(p1->next);.下載可編輯 ./*查看數據函數*/stu *lookdata(stu *p1)while(p1!=N

15、ULL)printf("Name:%st",p1->name);printf("Num:%dt",p1->num);printf("Sex:%st",p1->sex);printf("n");printf("Physic:%ft",p1->physic);printf("Math:%ft",p1->mathematic);printf("English:%ft",p1->english);printf("Com

16、puter:%ft",p1->computer);printf("n");p1=p1->next;return p1;/*通過比較學號來插入數據的函數*/void insert() stu *p1,*p3,*p2; p1=head; p3=(stu*)malloc(sizeof(stu);p3->next=NULL;if(head=NULL) head=p3;return; cin(p3);while(p1!=NULL&&(p1->num<p3->num) p2=p1;p1=p1->next; if(p2=

17、head) p3->next=head; head=p3;return; p3->next=p1;p2->next=p3;.下載可編輯 ./*通過姓名來查找的函數*/void find(stu *p2) char name20; int b=0;printf("Enter the name of the sutdent you want to find:"); scanf("%s",name);while(p2!=NULL)if(strcmp(name,p2->name)=0) printf(" The data you

18、 want has be find "); printf("Name:%st",p2->name); printf("Num:%dt",p2->num); printf("Sex:%st",p2->sex); printf("n"); printf("Physic%ft",p2->physic); printf("Math%ft",p2->mathematic); printf("English%ft",p2->

19、;english); printf("Computer%ft",p2->computer); printf("n");b=1;else if(b=0)printf("sorry not find data!");p2=p2->next;if(b=1)print();printf("Find onen");elseprint();printf("Not findn");.下載可編輯 ./*求各學生物理平均成績*/void paverage() stu *p1; int i;float

20、max=0.0,min=200.0; float sum=0.0,aver=0;p1=head;if(p1=NULL) printf("not data!"); else for(i=0;p1!=NULL;p1=p1->next) sum+=p1->physic; aver=sum/i;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(max<p1->physic) max=p1->physic;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p

21、1->physic)min=p1->physic;printf("Physic Average:%f ",aver);printf("Physic Max:%f",max);printf("Physic Min:%f",max);/* 求各學生數學平均分最高和最低分成績的函數*/.下載可編輯 .void maverage() stu *p1; int i;float max=0.0,min=200.0; float sum=0.0,aver=0; p1=head; if(p1=NULL) printf("not

22、data!");elsefor (i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->mathematic; aver=sum/i;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->mathematic) max=p1->mathematic;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p1->mathematic)min=p1->mathematic;printf("Math Avera

23、ge:%f",aver);printf("Math Max:%f",max);printf("Math Min:%f",min);/* 求各學生英語平均分最高和最低分成績的函數*/void eaverage() stu *p1;int i;float max=0.0,min=200.0; float sum=0.0,aver=0; p1=head;.下載可編輯 .if(p1=NULL)printf("not data!");elsefor(i=0;p1!=NULL;i+,p1=p1->next)sum+=p1->

24、english;aver=sum/i;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->english) max=p1->english;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p1->english)min=p1->english;printf("English Average:%f",aver);printf("English Max:%f",max);printf("English M

25、in:%f",min);/* 求各學生計算機平均成績最高和最低分 */void comaverage() stu *p1; int i;float max=0.0,min=200.0;float sum=0.0,aver=0;p1=head;if(p1=NULL)printf("not data!");elsefor(i=0;p1!=NULL;i+,p1=p1->next)sum+=p1->computer;aver=sum/i;p1=head;.下載可編輯 .for(i=0;p1!=NULL;i+,p1=p1->next) if(max<

26、p1->computer)max=p1->computer;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p1->computer)min=p1->computer;printf("Computer Average:%f",aver);printf("Computer Max:%f",max);printf("Computer Min:%f",min);/* 統計物理平均和總分*/void aver_sum_physic() stu *p1; int

27、i;float sum=0,aver; p1=head; if(p1=NULL)printf("not data!"); else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->physic; aver=sum/i;printf("Physic Average:%f",aver);printf("Physic Sum:%f",sum);/* 統計數學平均和總分*/void aver_sum_mathematic() stu *p1; int i;.下載可編輯 .float sum=0,

28、aver;p1=head;if(p1=NULL)printf("not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->mathematic; aver=sum/i;printf("Mathematic Average:%f",aver);printf("Mathematic Sum:%f",sum);/* 統計英語平均和總分*/void aver_sum_english() stu *p1; int i;float sum=0,aver; p1=head; i

29、f(p1=NULL)printf("not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->english; aver=sum/i;printf("English Average:%f",aver);printf("English Sum:%f",sum);/* 統計計算機平均和總分*/void aver_sum_computer() stu *p1; int i;float sum=0,aver; p1=head;if(p1=NULL) printf(&quo

30、t;not data!");else.下載可編輯 . for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->computer; aver=sum/i;printf("Computer Average:%f",aver);printf("Computer Sum:%f",sum);/* 統計模塊 */void count() int choice;doprintf(" *統計學生平均分和總分 *n");printf("<1>:物理平均和總分 n");pr

31、intf("<2>:數學平均和總分 n");printf("<3>:英語平均和總分 n");printf("<4>:計算機平均和總分 n");printf("<0>返回主菜單 :n");printf("請選擇 (04):n");scanf("%d",&choice);switch(choice) case 1:aver_sum_physic();break;case 2:aver_sum_mathematic();bre

32、ak;case 3:aver_sum_english();break;case 4:aver_sum_computer();break;case 0:break;while(choice!=0);/* 物理成績排序*/* 庫存排行 */sort_physic()int i=1,j=1;.下載可編輯 .float min;stu *newh,*newp,*tp1,*tp2,*p;newp=newh=NULL;tp1=tp2=NULL;p=head;doi+;p=p->next;while(p->next);while(head!=NULL)p=head;tp1=tp2=p;min=p

33、->physic;while(p->next!=NULL)if(p->next->physic<min)min=p->next->physic;tp1=p;tp2=p->next;p=p->next;if(newh=NULL)newp=newh=tp2;elsenewp->next=tp2;newp=tp2;if(tp2=head)head=tp2->next;elsetp1->next=tp2->next;tp2->next=NULL;head=newh;p=head;for(j=1;j<=i;j+)i

34、f(p!=NULL).下載可編輯 .printf("n物理成績排行 n");printf("-");printf("n排名姓名性別學號物理成績 n");printf("n%18d %6s %8s %11d %10fn",j,p->name,p->sex,p->num,p->physic);p=p->next;else break;printf("n按任意鍵返回n");getch();/* 刪除相關數據*/shanchu() int num; stu *p,*p0;

35、p=head; cin(p);printf(" 請輸入要刪除的學號 :"); scanf("%d",&num); head=p->next;free(p);return 1;p0=p->next;while(p0!=NULL)if(p0->num=num)p->next=p;free(p0);return 1;p=p0;p0=p0->next;return 0;.下載可編輯 ./* 修改模塊 */void revise_message(stu *h)int choice,revise_num,flag;stu *p;

36、p=head;doprintf("n輸入要修改的學生的學號:");scanf("%d",&revise_num);while(p->num!=revise_num)p=p->next;/*查找 */if(p->num=revise_num)printf("n-學生信息 -n");n");printf("學號 - 姓名 - 性別 - 物理成績 - 數學成績 - 英語成績 - 計算機成績 n");printf("%8s%4d%8s%8f%8f%8f%8fn",p-

37、>name,p->num,p->sex,p->physic,p->mathematic,p->english,p->computer);printf("n您要修改哪一項 ?n");printf("n1、姓名 n");printf("n2、學號 n");printf("n3、性別 n");printf("n4物理成績 n");printf("n5、數學成績 n");printf("n6、英語成績 n");printf

38、("n7、計算機成績 n");printf("n請選擇( 1-7 ) :");scanf("%d",&choice);switch(choice).下載可編輯 .case 1:printf("n輸入修改后的學生姓名:");scanf("%s",p->name);break;case 2:printf("n輸入修改后的學生學號:");scanf("%d",p->num);break;case 3:printf("n輸入修改后的性

39、別:");scanf("%s",&p->sex);case 4:printf("n輸入修改后的物理成績:");scanf("%f",&p->physic);case 5:printf("n輸入修改后的數學成績:");scanf("%f",&p->mathematic);case 6:printf("n輸入修改后的英語成績:");scanf("%f",&p->english);break;ca

40、se 7:printf("n輸入修改后的計算機成績:");scanf("%f",&p->computer);break;printf("-n");printf("學號 - 姓名 - 性別 - 物理成績 - 數學成績 - 英語成績 - 計算機成績 n");printf("%8s%4d%8s%8f%8f%8f%8fn",p->name,p->num,p->sex,p->physic,p->mathematic,p->english,p->com

41、puter);break;if(p->next=NULL)printf("n該學生不存在!");printf("nn 要繼續嗎 ?(y/n)"); choice=getch();if(choice='y')|(choice='Y').下載可編輯 .printf("n繼續 !n");flag=1;else flag=0;while(flag=1);printf("n按任意鍵返回主菜單!n");/* 更新模塊 */void renew_message() int choice;do

42、 printf("nn*更新學生信息 *nn");printf("1.添加信息 nn");printf("2.刪除信息 nn");printf("3.修改信息 nn");printf("4.返回主菜單 nn");printf("請選擇( 03) :");scanf("%d",&choice);switch(choice) case 1: insert();break; case 2: shanchu();break;case 3: revise_m

43、essage(head);break;case 0:;break;while(choice!=0);/* 保留數據函數*/void save(stu *p2) FILE *fp;char file10;printf("Enter file name");scanf("%s",file);fp=fopen(file,"w");while(p2!=NULL)fprintf(fp,"%s",p2->name);fprintf(fp,"%d",p2->num);fprintf(fp,&quo

44、t;%s",p2->sex);fprintf(fp,"%f",p2->physic);fprintf(fp,"%f",p2->mathematic);.下載可編輯 .fprintf(fp,"%f",p2->english);fprintf(fp,"%f",p2->computer);p2=p2->next;fclose(fp);/*主函數 */char password7="123456"void main()/*初始化 */char choices

45、;stu *p2;char s8;int flag=0,i;/*標志項 */int n=3;sum=read_message();doprintf("Enter password:n");scanf("%s",s);if(!strcmp(s,password) printf("PASSnnn");flag=1;break;elseprintf(" Error Enter againn");n-;while(n>0);if(!flag) printf("You have Enter 3 times!"); exit(0);.下載可編輯 .printf(&quo

溫馨提示

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

評論

0/150

提交評論