版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)題目 : 學(xué)生成績管理系統(tǒng)一、 實(shí)驗(yàn)?zāi)康?. 熟悉 c 語言的編譯連接和運(yùn)行過程。2. 掌握 c 語言的數(shù)據(jù)類型,熟悉整型、實(shí)型、字符型變量的定義方式及如何給 它們賦值。3. 掌握 if 語句及 switch 語句的運(yùn)用方法及嵌套應(yīng)用方法。4. 掌握實(shí)現(xiàn)循環(huán)結(jié)構(gòu)的三種語句 while 、 do-while. 、 for 的使用。5. 掌握函數(shù)的定義方法和調(diào)用方法。6. 能夠采用模塊化思想調(diào)試程序。二實(shí)驗(yàn)內(nèi)容1. 編寫程序并進(jìn)行調(diào)試運(yùn)行。2. 輸入學(xué)生資料 ,并保存于文件。每個學(xué)生包含信息如:姓名、學(xué)號、性別、物 理成績、數(shù)學(xué)成績、英語成績、計算機(jī)成績。3. 對已存入的學(xué)生信息進(jìn)行更新操作
2、,包括更新學(xué)生信息信息、 刪除某個學(xué)生信 息和修改學(xué)生信息。4. 通過按學(xué)生姓名的方式查詢學(xué)生信息。5. 輸入某學(xué)生各門成績進(jìn)行統(tǒng)計。6 對學(xué)生物理成績排序。7. 最后輸出學(xué)生信息,供需要時打印。二、 需求分析1. 該程序可用于對學(xué)生的基本信息的存儲、更新、查詢、輸出、統(tǒng)計、排序等 操作。2. 其中更新功能包括:添加信息、刪除信息、修改信息、可根據(jù)需要添加一個 或多個學(xué)生 信息 ,也可對個別學(xué)生信息進(jìn)行適當(dāng)?shù)膭h除或修改。以便隨時更 新學(xué)生信息。3. 程序中設(shè)計的查詢功能可根據(jù)需要從若干數(shù)據(jù)中查詢某信息,四、概要設(shè)計1、方案設(shè)計 對系統(tǒng)進(jìn)行分析,給出結(jié)構(gòu)圖 分析:系統(tǒng)要求實(shí)現(xiàn)許多的功能, 因此遵
3、循結(jié)構(gòu)化程序設(shè)計思想來進(jìn)行本系統(tǒng)的設(shè)計自頂向下、 逐步細(xì)化, 將系統(tǒng)設(shè)計任務(wù)分解出許多子功能模塊進(jìn)行設(shè)計結(jié)構(gòu)圖如下:學(xué)生成績管五功能模塊的說明1輸入初始學(xué)生信息:其中包括學(xué)生姓名,學(xué)號,性別,物理數(shù)學(xué) 英語 計算機(jī)成績 等相關(guān)信息;可用函數(shù)cin(stu *p1)來實(shí)現(xiàn)此操作。2查詢模塊:可用stu *lookdata(stu *p1)來實(shí)現(xiàn)。找到就輸出此學(xué)生全部信息包 括學(xué)生物理數(shù)學(xué)英語計算機(jī)的成績。3插入模塊:可用in sert()來實(shí)現(xiàn)。其中通過學(xué)號的大小比較的,并且以此來排 序。4輸出學(xué)生的信息及成績:通過學(xué)生的姓名來查看學(xué)生的語文數(shù)學(xué) 英語 計算機(jī)的有關(guān)成績,同時也可以分別通過 pa
4、verage() maverage() eaverage() comaverage() 來輸出物理 數(shù)學(xué) 英語 計算機(jī)等成績的平均分 最高分 最低分。5退出系統(tǒng):可以用一個函數(shù)來實(shí)現(xiàn),首先將信息保存在文件中,釋放動態(tài)創(chuàng)建 的內(nèi)存空間,再退出次程序。流程圖如下 六.調(diào)試情況及運(yùn)行結(jié)果1、對自己設(shè)計進(jìn)行評價,指出合理和不足之處,提出改進(jìn)的方案。此次實(shí)踐課編寫的是一個應(yīng)用程序, 相對于以前我們見到的程序,它要大得多,于是就按課本上的例子編了超市管理系統(tǒng), 先把界面弄好然后 再添加各模塊,而且各模塊也出現(xiàn)了不少問題,在同學(xué)們和老師的幫助下,我很有耐心的一次又一次的進(jìn)行修改,最后運(yùn)行的結(jié)果基本上達(dá)到了預(yù)
5、期 的目的??山Y(jié)果還不是太理想。由于時間很短,在選題報告中設(shè)想到的好多功能都沒有實(shí)現(xiàn)。 已有的 那些功能雖已能基本上滿足管理者和消費(fèi)者的需要,但如果還有更多的功 能程序就會更加完美。如:進(jìn)入系統(tǒng)時沒有設(shè)制密碼,保護(hù)性不夠強(qiáng);在 輸入商品號時沒有出錯提示,如果商品號輸入負(fù)值2、在設(shè)計過程中的感受本次C語言的實(shí)習(xí)課讓我對C語言的學(xué)習(xí)又有了更深入的了解,也讓 我更深刻地領(lǐng)悟到了 “實(shí)踐出真理”這個道理,在上機(jī)實(shí)踐過程中學(xué)到的 知識遠(yuǎn)遠(yuǎn)超過了在課堂上十幾周學(xué)到的,學(xué)校組織的這次實(shí)習(xí)讓我們這些 實(shí)踐知識匱乏的大學(xué)生增添了許多社會經(jīng)驗(yàn),為我們將來走上工作崗位其 了不小的鋪墊作用。本次實(shí)習(xí)中遇到了很多以前沒
6、有遇到過的問題,也曾想過要放棄,但看到那些同學(xué)都在那認(rèn)真的寫程序,給了我繼續(xù)的信心。在同學(xué)的幫助下,我 順利的結(jié)束了本次實(shí)習(xí),讓我知道原來憑借自己努力取得的成功會讓自己 這么欣慰,也讓我知道了友誼和團(tuán)結(jié)的重要性。七參考文獻(xiàn)C語言程序設(shè)計王曙燕 曹錳科學(xué)出版社八。附錄:#in clude <stdio.h>#in clude <stddef.h>#in clude <stddef.h>/* 定義結(jié)構(gòu)體 */*姓名 */*學(xué)號 */* 性別 */ /*語文 */ /*數(shù)學(xué) */ /* 英語*/ /* 計算機(jī) */ /* 結(jié)構(gòu)體指針 */#include <
7、string.h> #include <stdlib.h> #include <conio.h> #define MAX 10 int sum=10;typedef struct studentchar nameMAX; int num;char sexMAX; float physic;float mathematic; float english;float computer; struct student *next;stu;stu *head;/* 讀取信息 */int read_message() FILE *fp;stu *p;int i=0; if(
8、fp=fopen("student_manage.txt","rb")=NULL) printf("nn* 暫時還沒有任何信息,輸入密碼進(jìn)入主菜單選擇基本信息錄入! *n");return 0;while(feof(fp)!=1) fread(head,sizeof(stu),1,fp);if(p->num=0) break;else i+;fclose(fp);return(i);/* 顯示或打印函數(shù) */void print()printf("ttt Score Manage Systemn");/* 成
9、績管理系統(tǒng)*/printf("ttt 成績管理系統(tǒng) n");printf("<1>Enter Record :輸入數(shù)據(jù)n");/* 輸入數(shù)據(jù)*/printf("<2>Display :顯示或打印n");/* 顯示*/printf("<3>find :查找數(shù)據(jù)n");/* 訪問數(shù)據(jù)*/printf("<4>Renew_message:更新模塊n"); /* 更新模塊 */printf("<5>Save:保存數(shù)據(jù)n");
10、printf("理成績排名 */<6>sort_physic:成績排名n"); /* 物printf("數(shù)據(jù)統(tǒng)計 */<7>Count:數(shù)據(jù)統(tǒng)計n"); /*printf("理平均成績 */<8>Physic Average:物理平均成績n"); /* 物printf(" 數(shù)學(xué)平均成績 */<9>Math Average:數(shù)學(xué)平均成績n"); /*printf("語平均成績 */<10>English Average:英語平均成績n")
11、; /* 英printf("計算機(jī)平均成績 */<11>Computer Average: 計算機(jī)平均成績n"); /*printf("<12>Quit :退出tn");/*退出 */* 輸入相關(guān)數(shù)據(jù)函數(shù) */void cin(stu *p1)printf("n Enter name:n"); scanf("%s",&p1->name); printf("Enter num:n"); scanf("%d",&p1->num)
12、; printf("Enter sex:n");scanf("%s",&p1->sex); printf("Enter scoren");printf("Enter physic:n"); scanf("%f",&p1->physic);printf("Enter mathematic:n"); scanf("%f",&p1->mathematic);printf("Enter english:n&quo
13、t;); scanf("%f",&p1->english);printf("Enter computer:n"); scanf("%f",&p1->computer);/* 其他數(shù)據(jù)是否輸入函數(shù) */ stu *cindata() stu *p1,*p2;int i=1;char ch;p1=(stu*)malloc(sizeof(stu); head=p1;while(i) cin(p1);printf("Do you want to continue?Yes or no:n"); f
14、flush(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);/* 查看數(shù)據(jù)函數(shù) */stu *lookdata(stu *p1)while(p1!=NULL) printf("Name:%st",p1->name); printf("Num:%dt",p1->num); printf(&q
15、uot;Sex:%st",p1->sex); printf("n");printf("Physic:%ft",p1->physic); printf("Math:%ft",p1->mathematic); printf("English:%ft",p1->english);printf("Computer:%ft",p1->computer); printf("n");p1=p1->next;return p1;/* 通過比較學(xué)號
16、來插入數(shù)據(jù)的函數(shù) */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=head) p3->next=head; head=p3;return; p3->next=p1;p2->next=p3;/* 通過姓名來查找的函數(shù) */void
17、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 want has be find "); printf("Name:%st",p2->name); printf("Num:%dt",p2
18、->num); printf("Sex:%st",p2->sex); printf("n"); printf("Physic%ft",p2->physic); printf("Math%ft",p2->mathematic); printf("English%ft",p2->english); printf("Computer%ft",p2->computer); printf("n");b=1;else if(b=0)
19、printf("sorry not find data!");p2=p2->next;if(b=1)print();printf("Find onen");elseprint(); printf("Not findn");/* 求各學(xué)生物理平均成績 */ void paverage() 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!");else for(i=0;p1
20、!=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>p1->physic) min=p1->physic;printf("Physic Average:%f ",aver); printf("Physic Max:%f"
21、;,max); printf("Physic Min:%f",max);/* 求各學(xué)生數(shù)學(xué)平均分 最高和最低分成績的函數(shù) */ 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 data!");elsefor (i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->mathematic; aver=sum/i;p1=head;for(i=0;p1!=NULL;i
22、+,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 Average:%f",aver);printf("Math Max:%f",max);printf("Math Min:%f",min);/* 求各學(xué)生英語平均分 最高和最低分成績的函數(shù)
23、 */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->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(
24、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 Min:%f",min);/* 求各學(xué)生計算機(jī)平均成績 最高和最低分 */void comaverage() stu *p1;int i;float max=0.0,min=200.0;float sum=0.0,aver=0;p
25、1=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<p1->computer)max=p1->computer;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next) if(min>p1->computer) min=p1->comput
26、er;printf("Computer Average:%f",aver); printf("Computer Max:%f",max); printf("Computer Min:%f",min);/* 統(tǒng)計物理平均和總分 */void aver_sum_physic() stu *p1;int 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->
27、;physic; aver=sum/i;printf("Physic Average:%f",aver);printf("Physic Sum:%f",sum);/* 統(tǒng)計數(shù)學(xué)平均和總分 */void aver_sum_mathematic() stu *p1;int 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->mathematic; aver=sum/i;p
28、rintf("Mathematic Average:%f",aver); printf("Mathematic Sum:%f",sum);/* 統(tǒng)計英語平均和總分 */void aver_sum_english() stu *p1;int 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->english; aver=sum/i;printf("Englis
29、h Average:%f",aver);printf("English Sum:%f",sum);/* 統(tǒng)計計算機(jī)平均和總分 */void aver_sum_computer() stu *p1;int 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->computer; aver=sum/i;printf("Computer Average:%f",av
30、er); printf("Computer Sum:%f",sum);/* 統(tǒng)計模塊 */void count() int choice;doprintf(" * 統(tǒng)計學(xué)生平均分和總分 *n"); printf("<1>: 物理平均和總分n");printf("<2>: 數(shù)學(xué)平均和總分n");printf("<3>: 英語平均和總分n");printf("<4>: 計算機(jī)平均和總分 n");printf(" <0
31、> 返回主菜單 :n"); printf("請選擇 (04):n");scanf("%d",&choice);switch(choice) case 1:aver_sum_physic();break;case 2:aver_sum_mathematic();break;case 3:aver_sum_english();break;case 4:aver_sum_computer();break;case 0:break;while(choice!=0);/* 物理成績排序 */* 庫存排行 */sort_physic()int
32、 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->physic; while(p->next!=NULL)if(p->next->physic<min)min=p->next->physic;tp1=p;tp2=p->next;p=p->next;if(newh=NU
33、LL) 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+)if(p!=NULL)printf("n物理成績排行 nprintf("");printf("n排名 姓名 性別 學(xué)號);物理成績 n");printf("n%18d %6s %8s %11d %10fn&quo
34、t;,j,p->name,p->sex,p->num,p->physic); p=p->next;else break;printf("n 按任意鍵返回 n");getch();/* 刪除相關(guān)數(shù)據(jù) */shanchu() int num;stu *p,*p0;p=head;cin(p);printf(" 請輸入要刪除的學(xué)號 :"); scanf("%d",&num); head=p->next;free(p);return 1;p0=p->next;while(p0!=NULL)if(
35、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;p=head;doprintf("n 輸入要修改的學(xué)生的學(xué)號 :"); scanf("%d",&revise_num);while(p->num!=revise_num)p=p->next; /* 查找 */ if(p->num=re
36、vise_num)printf("n- 學(xué)生信息 -n");printf("n");printf(" 學(xué)號 -姓名 -性別 - 物理成績 -數(shù)學(xué)成績 -英語成績 -計算機(jī)成績 n");printf("%8s%4d%8s%8f%8f%8f%8f n",p->name,p->num,p->sex,p->physic,p->mathematic,p->english,p->computer);printf("n您要修改哪一項(xiàng)?n");printf("
37、n1、姓名 n");printf("n2、學(xué)號 n");printf("n3、性別 n");printf("n4物理成績n");printf("n5、數(shù)學(xué)成績n");printf("n6、英語成績n");printf("n7、計算機(jī)成績n");printf("n請選擇( 1-7) :");scanf("%d",&choice);switch(choice)case 1:printf("n輸入修改后的學(xué)生姓名
38、:");scanf("%s",p->name);break;case 2:printf("n 輸入修改后的學(xué)生學(xué)號 :");scanf("%d",p->num);break;case 3:printf("n輸入修改后的性別 :");scanf("%s",&p->sex);case 4:printf("n輸入修改后的物理成績 :");scanf("%f",&p->physic);case 5:printf(&
39、quot;n輸入修改后的數(shù)學(xué)成績 :");scanf("%f",&p->mathematic);case 6:printf("n輸入修改后的英語成績 :");scanf("%f",&p->english);break;case 7:printf("n輸入修改后的計算機(jī)成績 :");scanf("%f",&p->computer);break;printf("n");printf(" 學(xué)號 -姓名 -性別 - 物理成
40、績 - 數(shù)學(xué)成績 -英語成績 - 計算機(jī)成績n");printf("%8s%4d%8s%8f%8f%8f%8fn",p->name,p->num,p->sex,p->physic,p->mathematic,p->english,p->computer);break; if(p->next=NULL)該學(xué)生不存在! ");printf("nprintf("nn 要繼續(xù)嗎 ?(y/n)"); choice=getch();if(choice='y')|(choic
41、e='Y')printf("n 繼續(xù) !n"); flag=1;else flag=0;while(flag=1);printf("n 按任意鍵返回主菜單 !n"); /* 更新模塊 */void renew_message() int choice;do printf("nn printf(" printf(" printf(" printf(" printf("* 更新學(xué)生信息 *nn");1.添加信息 nn");2.刪除信息 nn");3.修改
42、信息 nn");4.返回主菜單 nn");請選擇( 03) :");scanf("%d",&choice);switch(choice) case 1: insert();break;case 2: shanchu();break;case 3: revise_message(head);break;case 0:;break;while(choice!=0);/* 保留數(shù)據(jù)函數(shù) */void save(stu *p2) FILE *fp;char file10;printf("Enter file name");
43、scanf("%s",file); fp=fopen(file,"w");while(p2!=NULL) fprintf(fp,"%s",p2->name); fprintf(fp,"%d",p2->num); fprintf(fp,"%s",p2->sex); fprintf(fp,"%f",p2->physic); fprintf(fp,"%f",p2->mathematic); fprintf(fp,"%f&q
44、uot;,p2->english); fprintf(fp,"%f",p2->computer); p2=p2->next;fclose(fp);/*主函數(shù) */char password7="123456"/* 初始化 */* 標(biāo)志項(xiàng) */void main()char choices; 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(&
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年粵教版必修2地理上冊月考試卷含答案
- 2025年常州機(jī)電職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測試近5年常考版參考題庫含答案解析
- 2025年山西交通職業(yè)技術(shù)學(xué)院高職單招語文2018-2024歷年參考題庫頻考點(diǎn)含答案解析
- 2025年唐山職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測試近5年??及鎱⒖碱}庫含答案解析
- 2025年咸寧職業(yè)技術(shù)學(xué)院高職單招職業(yè)適應(yīng)性測試近5年??及鎱⒖碱}庫含答案解析
- 2025年南充電影工業(yè)職業(yè)學(xué)院高職單招高職單招英語2016-2024歷年頻考點(diǎn)試題含答案解析
- 2025年北京科技經(jīng)營管理學(xué)院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 2025至2031年中國氫氣鉬絲電阻爐行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國四氟塑膠O型圈行業(yè)投資前景及策略咨詢研究報告
- 新興市場投資策略-第1篇-深度研究
- 某房屋建筑工程監(jiān)理大綱
- 英語考綱詞匯表3500詞
- 主題一:人文之美 第7課《天下第一大佛-樂山大佛》 課件
- 印度與阿拉伯的數(shù)學(xué)
- 會陰切開傷口裂開的護(hù)理查房
- 《鋼鐵是怎樣煉成的》選擇題100題(含答案)
- 2024年國新國際投資有限公司招聘筆試參考題庫含答案解析
- 食堂餐廳服務(wù)方案投標(biāo)方案(技術(shù)標(biāo))
- Creo-7.0基礎(chǔ)教程-配套課件
- 六年級人教版上冊數(shù)學(xué)計算題練習(xí)題(及答案)100解析
- 超聲科質(zhì)量控制制度及超聲科圖像質(zhì)量評價細(xì)則
評論
0/150
提交評論