學(xué)生管理系統(tǒng)_第1頁
學(xué)生管理系統(tǒng)_第2頁
學(xué)生管理系統(tǒng)_第3頁
學(xué)生管理系統(tǒng)_第4頁
學(xué)生管理系統(tǒng)_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、 湖南大學(xué) C語言工程實訓(xùn)報告 題 目: 學(xué)生成績管理系統(tǒng) 學(xué)院名稱: 土木工程學(xué)院 專業(yè)班級: 土木工程1101班 學(xué)生姓名: 陳太平 學(xué) 號: 20110101131 指導(dǎo)老師: 李 春 翔 目錄第一節(jié) c語言工程實訓(xùn)意義-起始頁碼 1.1 c語言工程訓(xùn)練目的及要求-起始頁 1.2 c語言工程訓(xùn)練內(nèi)容及意義-起始頁 1.3 c語言選題及題目的應(yīng)用-起始頁第二節(jié) 項目定義和需求分析-起始頁碼 2.1 項目功能需求-起始頁碼- 2.2 主要數(shù)據(jù)結(jié)構(gòu)-起始頁碼第三節(jié) 項目設(shè)計-起始頁碼3.1 主要算法描述-起始頁碼- 3.2 主要數(shù)據(jù)結(jié)構(gòu)設(shè)計-起始頁碼第四節(jié) 實訓(xùn)項目測試-起始頁碼第五節(jié) 工程實

2、訓(xùn)小結(jié)-起始頁碼- 參考文獻-起始頁碼-附圖 第一節(jié) c語言工程實訓(xùn)意義 一 c語言工程訓(xùn)練目的及要求本綜合訓(xùn)練是計算機科學(xué)與技術(shù),信息管理與信息系統(tǒng),軟件工程專業(yè)重要的實踐環(huán)節(jié)之一,是學(xué)生學(xué)習(xí)完程序設(shè)計課程和c語言編程后進行的一次全面綜合訓(xùn)練.本課綜合訓(xùn)練的目的和任務(wù):1. 鞏固和加深學(xué)生對c語言,數(shù)組結(jié)構(gòu)課程的基本知識的理解和掌握;2. 掌握c語言編程和程序調(diào)試的基本技能;3. 利用c語言進行基本的軟件設(shè)計;4. 掌握書寫程序設(shè)計說明文檔的能力;5. 提高運用c語言,數(shù)組結(jié)構(gòu)解決實際問題的能力.二 c語言工程訓(xùn)練內(nèi)容及意義 本選題任務(wù)為制作一個學(xué)生成績管理系統(tǒng),要求對學(xué)生成績進行一定的處理

3、,比如說求各科總分,平均分等,在程序中要用到數(shù)組結(jié)構(gòu),結(jié)構(gòu)體機構(gòu),要靈活的處理插入,輸出,查詢,修改,保存的程序,要對程序進行估分,評判優(yōu)劣.通過學(xué)習(xí)這門課,培養(yǎng)學(xué)生自學(xué)能力和動手能力,接受新知識的能力,提高學(xué)習(xí)興趣,增強學(xué)生程序設(shè)計能力,為以后學(xué)習(xí)與工作打下堅實的基礎(chǔ).三 c語言選題及題目的應(yīng)用 我所選擇的題目為:學(xué)生成績管理系統(tǒng).通過這個系統(tǒng),我們可以很方便的操作學(xué)生成績,在短時間內(nèi),求出學(xué)生總分,加權(quán)分等,完成大量的工作,高效快速,在極其危急情況下,為我們贏得了時間,贏得了效率. 第二節(jié) 項目定義和需求分析一 項目功能需求 該程序主要分為機構(gòu)題定義,程序子函數(shù)的定義,主函數(shù)的編寫三大部分

4、,主要分支結(jié)構(gòu)如下: 主函數(shù)語文成績數(shù)學(xué)成績英語成績編程成績數(shù)據(jù)輸入函數(shù)查看數(shù)據(jù)函數(shù)插入數(shù)據(jù)函數(shù)查找數(shù)據(jù)函數(shù)平均成績輸出更新數(shù)據(jù)函數(shù)保存數(shù)據(jù)函數(shù)加權(quán)成績計算二 主要數(shù)據(jù)結(jié)構(gòu) 主要的數(shù)據(jù)結(jié)構(gòu)有: 結(jié)構(gòu)體的定義:typedef struct student char nameMAX; /*姓名*/int num; /*學(xué)號*/char sexMAX; /*性別*/int chinese; /*語文*/int mathematic; /*高數(shù)*/int english; /*英語*/int computer; /*編程*/struct student *next; /*結(jié)構(gòu)體指針*/stu; 在這個

5、結(jié)構(gòu)體定義中,總共定義了八個成員,包括姓名,性別,學(xué)號,語文成績,數(shù)學(xué)成績,英語成績,計算機成績以及結(jié)構(gòu)體指針.前面幾個用于存放數(shù)據(jù),結(jié)構(gòu)體指針是用來鏈接下一個學(xué)生數(shù)據(jù)的.這其中包含有數(shù)組結(jié)構(gòu)等等.第3節(jié) 項目設(shè)計一 主要算法描述 主要算法有平均成績(其中還包括最高分與最低分的計算)的計算和加權(quán)成績的計算. 主要算法有平均成績的計算程序如下: /*求學(xué)生語文平均分,最高分和最低分的函數(shù)*/void caverage() stu *p1;int i;float max=0.0,min=100.0;float sum=0.0,aver=0.0;p1=head;if(p1=NULL) printf(

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

7、"chinese average:%ft",aver); printf("chinese max:%ft",max); printf("chinese min:%fn",min);在這個算法中就是對每個人的語文成績求和再除以總的人數(shù)得到了全部同學(xué)的語文成績的平均分,還可以用此函數(shù)求的各課的最高分與最低分.不管計算均分還是最值分都需要用到for循環(huán)函數(shù)./*求加權(quán)成績*/void jiaquan(stu *p1) int c=2,m=4,e=2,com=3; /*語文2學(xué)分,數(shù)學(xué)4學(xué)分,英語2學(xué)分,計算機3學(xué)分*/float p,sum

8、=0;while(p1!=NULL)sum=p1->chinese*2+p1->mathematic*4+p1->english*2+p1->computer*3;p=sum/11; printf("%st",p1->name);printf("%fn",p);p1=p1->next; 在這個函數(shù)中,加權(quán)成績=學(xué)科分數(shù)*學(xué)分/總學(xué)分,用while循環(huán)先求和(sum=p1->chinese*2+p1->mathematic*4+p1->english*2+p1->computer*3;)再求平均,

9、對于科目的學(xué)分為定數(shù),先提前定義(int c=2,m=4,e=2,com=3).二 主要數(shù)據(jù)結(jié)構(gòu)設(shè)計1.數(shù)據(jù)輸入函數(shù):void cin(stu *p1)/*輸入一個人的成績*/ printf("enter name:");scanf("%s",p1->name);printf("nenter num:");scanf("%d",&p1->num);printf("nenter sex:");scanf("%s",p1->sex);printf(&qu

10、ot;nenter score:nn");printf("enter chinese:");scanf("%d",&p1->chinese);printf("nenter math:");scanf("%d",&p1->mathematic);printf("nenter english:");scanf("%d",&p1->english);printf("nenter computer:");scan

11、f("%d",&p1->computer);stu *cindata()/*在輸入成績*/stu *p1,*p2;int i=1;char chp1=(stu*)malloc(sizeof(stu);/*申請內(nèi)存空間*/head=p1;while(i)cin(p1);printf("do you want to continue?(n代表不再輸入,其他任意字符繼續(xù)輸入)n"); /*是否繼續(xù)輸入數(shù)據(jù)*/scanf(" %c",&ch);if(ch='n'|ch='N') /*不進行

12、再輸入*/i=0;p1->next=NULL; else /*進行再輸入*/ p2=p1;p1=(stu*)malloc(sizeof(stu);p2->next=p1;return(p1->next); 在這個輸入函數(shù)中總共兩個函數(shù),數(shù)據(jù)輸入函數(shù)與判斷數(shù)據(jù)是否繼續(xù)輸入函數(shù),數(shù)據(jù)輸入函數(shù)就是常規(guī)的按照c語言規(guī)則一個一個的進行輸入數(shù)據(jù),輸完之后退出.判斷是否繼續(xù)輸入函數(shù)就是要讓操作員操控輸入命令,從而才能繼續(xù)輸入.界面如下:2.插入函數(shù):void insert() stu *p1,*p2,*p3;p1=head;p3=(stu*)malloc(sizeof(stu);p3-&g

13、t;next=NULL;cin(p3);if(head=NULL) head=p3;return;while(p1!=NULL&&(p1->num<p3->num) /*通過比較學(xué)號來插入數(shù)據(jù)的函數(shù)*/ p2=p1;p1=p1->next;p3->next=p1;p2->next=p3;出入函數(shù)是通過比較輸入數(shù)據(jù)中的學(xué)號進行插入的,界面如下:查找函數(shù):void find(stu *p2) char name20;int b=1;printf("enter the name of the student you want to fin

14、d:n");scanf("%s",name);while(p2!=NULL) if(strcmp(name,p2->name)=0) printf("the data you want has be fonudn");printf("name:%st",p2->name);printf("num:%dt",p2->num);printf("sex:%st",p2->sex);printf("n");printf("chinese:%

15、dt",p2->chinese);printf("math:%dtt",p2->mathematic);printf("english:%dt",p2->english);printf("computer:%dt",p2->computer);printf("n");b=1;else if(b=0) printf("sorry not find data!"); p2=p2->next;if(b=1) printf("find onen"

16、;);else printf("not findn");查找函數(shù)要求用戶輸入要查找的學(xué)生姓名,即可看到該學(xué)生的全部成績,性別及學(xué)號.界面如下:3. 更新函數(shù):void update(stu *p2) char name10;int b=0;printf("enter name:");scanf("%s",name);while(p2!=NULL) if(strcmp(name,p2->name)=0) printf("find you datan");printf("name:");sca

17、nf("%s",p2->name);printf("n");printf("num:");scanf("%d",&p2->num);printf("n");printf("sex:");scanf("%s",p2->sex);printf("n");printf("chinese:");scanf("%d",&p2->chinese);printf(&quo

18、t;n");printf("math:");scanf("%d",&p2->mathematic);printf("n");printf("english:");scanf("%d",&p2->english);printf("n");printf("computer:");scanf("%d",&p2->computer);printf("n");printf(&

19、quot;success!");b=1;p2=p2->next;if(b=0)printf("sorry not find data!");else printf("nfinish!n");若是輸入信息錯誤,需要修改,就可以用這個函數(shù),只要輸入要修改的的學(xué)生姓名就可以對所有信息進行修改.4. 保存函數(shù)void save(stu *p2) FILE *fp;char file20;printf("enter the file name:");scanf("%s",file);fp=fopen(file

20、,"w");fprintf(fp,"namettmunttsexttchinesettmathematictenglishttcomputern");while(p2!=NULL) fprintf(fp,"%stt",p2->name);fprintf(fp,"%dtt",p2->num);fprintf(fp,"%stt",p2->sex);fprintf(fp,"%dtt",p2->chinese);fprintf(fp,"%dtt&qu

21、ot;,p2->mathematic);fprintf(fp,"%dtt",p2->english);fprintf(fp,"%dtt",p2->computer);fprintf(fp,"n");p2=p2->next;fclose(fp);printf("保存成功!");保存函數(shù)就是要把源代碼保存到文檔中,只要輸入要保存的文檔名就行啦,界面如下:第四節(jié) 實訓(xùn)項目測試第五節(jié) 工程實訓(xùn)小結(jié)經(jīng)過這次實訓(xùn)課是我掌握了很多關(guān)于計算機編程的知識,不管是在函數(shù)的定義方面還是在主函數(shù)界面的設(shè)計方面.這些

22、知識將會成為我以后學(xué)習(xí)的寶貴財富與經(jīng)驗.我希望學(xué)校在以后的教學(xué)中多多加入實訓(xùn)的科目,不僅能讓同學(xué)們有一個自我檢測的方式,還可以在共同的交流中學(xué)到更多的知識.源代碼:#include "stdio.h"#include"stddef.h"#include"string.h"#include"stdlib.h"#define MAX 10 /*宏定義*/char password7="123456" /*密碼初始化*/*定義結(jié)構(gòu)體*/typedef struct student char nameM

23、AX; /*姓名*/int num; /*學(xué)號*/char sexMAX; /*性別*/int chinese; /*語文*/int mathematic; /*高數(shù)*/int english; /*英語*/int computer; /*編程*/struct student *next; /*結(jié)構(gòu)體指針*/stu; stu *head; /*定義頭指針*/ /*函數(shù)聲明*/void print(); /*顯示菜單函數(shù)*/void cin(stu *p1); /*輸入相關(guān)數(shù)據(jù)的函數(shù)*/stu *cindata(); /*其他數(shù)據(jù)是否繼續(xù)輸入*/stu *lookdata(stu *p1); /

24、*查看數(shù)據(jù)的函數(shù)*/void insert(); /*通過比較學(xué)號來插入數(shù)據(jù)的函數(shù)*/void find(stu *p2); /*通過姓名查找查看數(shù)據(jù)的函數(shù)*/void caverage(); /*求個學(xué)生語文平均分,最高分和最低分的函數(shù)*/void maverage(); /*求個學(xué)生數(shù)學(xué)平均分,最高分和最低分的函數(shù)*/void eaverage(); /*求個學(xué)生英語平均分,最高分和最低分的函數(shù)*/void comaverage(); /*求個學(xué)生計算機平均分,最高分和最低分的函數(shù)*/void update(stu *p2); /*通過姓名查找來更新數(shù)據(jù)*/void save(stu *p

25、2); /*保存數(shù)據(jù)到文件*/void jiaquan(stu *p1); /*求加權(quán)成績*/*主函數(shù)*/void main() int choice;int flag=0,i; int n=3; stu *p2; char s8; doprintf("please enter password:n"); scanf("%s",s); if(!strcmp(s,password) printf("PASS!n"); flag=1; break; else printf("error enter againn");

26、n-; while(n>0); if(!flag) printf("you have enter 3 times!"); exit(0); printf("t-n");printf("t|ttttt|n");printf("t|ttttt|n"); printf("t=學(xué)生成績管理系統(tǒng)=n");printf("t|ttttt|n");printf("t|ttttt|n"); printf("t=%=n"); printf(&quo

27、t;是否進入(0代表退出)n "); scanf("%d",&choice); if(choice=0) /*0代表退出*/ exit(1); print(); while(1) printf("enter the your choice:n"); scanf("%d",&i); if(i<1|i>12) printf("enter num from 1 to 12:n"); exit(1); switch(i) case 1:p2=cindata(); break; case

28、 2:p2=lookdata(head); break; case 3:insert(); break; case 4:find(head); break; case 5:update(head); break; case 6:save(head); break; case 7:caverage(); break; case 8:maverage(); break; case 9:eaverage(); break;case 10:comaverage(); break; case 11:jiaquan(head); break; case 12:printf("退出成功!"

29、;);exit(1); break; printf("nnnn"); /*菜單*/void print() system("cls");/*清空頁面*/ printf("tt&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&n");printf("t

30、t&t 目錄 t&n");/*成績管理系統(tǒng)*/printf("tt&t<1>t輸 入 數(shù) 據(jù)t&n");/*輸入數(shù)據(jù)*/printf("tt&t<2>t查 看 數(shù) 據(jù)t&n");/*查看*/printf("tt&t<3>t插 入 數(shù) 據(jù)t&n"); /*插入數(shù)據(jù)*/printf("tt&t<4>t進 行 尋 找t&n");/*訪問,尋找數(shù)據(jù)*/printf("tt&am

31、p;t<5>t更 新 數(shù) 據(jù)t&n");/*更新數(shù)據(jù)*/printf("tt&t<6>t保 存 數(shù) 據(jù)t&n"); /*保存數(shù)據(jù)*/printf("tt&t<7>t語 文 平 均t&n"); /*語文平均成績*/printf("tt&t<8>t數(shù) 學(xué) 平 均t&n"); /*數(shù)學(xué)平均成績*/printf("tt&t<9>t英 語 平 均t&n"); /*英語平均成績*/pri

32、ntf("tt&t<10>t編 程 平 均t&n"); /*編程平均成績*/printf("tt&t<11>t加 權(quán) 成 績t&n");/*加權(quán)平均成績*/printf("tt&t<12>t退 出 系 統(tǒng)t&n"); /*退出*/printf("tt&&&&&&&&&&&&&&&&&&&&am

33、p;&&&&&&&&&&&&&n");/*成績輸入函數(shù)*/void cin(stu *p1)/*輸入一個人的成績*/ printf("enter name:");scanf("%s",p1->name);printf("nenter num:");scanf("%d",&p1->num);printf("nenter sex:");scanf("%s&q

34、uot;,p1->sex);printf("nenter score:nn");printf("enter chinese:");scanf("%d",&p1->chinese);printf("nenter math:");scanf("%d",&p1->mathematic);printf("nenter english:");scanf("%d",&p1->english);printf("n

35、enter computer:");scanf("%d",&p1->computer);stu *cindata()/*在輸入成績*/stu *p1,*p2;int i=1;char ch;p1=(stu*)malloc(sizeof(stu);/*申請內(nèi)存空間*/head=p1;while(i)cin(p1);printf("do you want to continue?(n代表不再輸入,其他任意字符繼續(xù)輸入)n"); /*是否繼續(xù)輸入數(shù)據(jù)*/scanf(" %c",&ch);if(ch='

36、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) printf("nametnumtsextchineset mathmatictenglisht computern");while(p1!=NULL)printf("%st%ldt%st%dt %dtt%dt %dtn&quo

37、t;,p1->name,p1->num,p1->sex,p1->chinese,p1->mathematic,p1->english,p1->computer);p1=p1->next;return p1;/*插入數(shù)據(jù)*/ void insert() stu *p1,*p2,*p3;p1=head;p3=(stu*)malloc(sizeof(stu);p3->next=NULL;cin(p3);if(head=NULL)head=p3;return;while(p1!=NULL&&(p1->num<p3->

38、;num) /*通過比較學(xué)號來插入數(shù)據(jù)的函數(shù)*/p2=p1;p1=p1->next;p3->next=p1;p2->next=p3;/*通過姓名查找查看數(shù)據(jù)函數(shù)*/void find(stu *p2) char name20;int b=1;printf("enter the name of the student you want to find:n");scanf("%s",name);while(p2!=NULL) if(strcmp(name,p2->name)=0) printf("the data you w

39、ant has be fonudn");printf("name:%st",p2->name);printf("num:%dt",p2->num);printf("sex:%st",p2->sex);printf("n");printf("chinese:%dt",p2->chinese);printf("math:%dtt",p2->mathematic);printf("english:%dt",p2->e

40、nglish);printf("computer:%dt",p2->computer);printf("n");b=1;else if(b=0) printf("sorry not find data!"); p2=p2->next;if(b=1) printf("find onen");else printf("not findn"); /*求學(xué)生語文平均分,最高分和最低分的函數(shù)*/void caverage() stu *p1;int i;float max=0.0,min=10

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

42、>p1->chinese) min=(float)p1->chinese; printf("chinese average:%ft",aver); printf("chinese max:%ft",max); printf("chinese min:%fn",min); /*求數(shù)學(xué)平均分,最高分和最低分*/void maverage() stu *p1;int i;float max=0.0,min=100.0;float sum=0.0,aver=0.0;p1=head;if(p1=NULL) printf(&qu

43、ot;not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum=sum+p1->mathematic; aver=sum/i; p1=head; for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->mathematic) max=(float)p1->mathematic; p1=head; for(i=0;p1!=NULL;i+,p1=p1->next) if(min>p1->mathematic) min=(float)p1->math

44、ematic; printf("math average:%ft",aver); printf("math max:%ft",max); printf("math min:%fn",min); /*求英語平均分,最高分和最低分*/void eaverage() stu *p1;int i;float max=0.0,min=100.0;float sum=0.0,aver=0.0;p1=head;if(p1=NULL) printf("not data!");else for(i=0;p1!=NULL;i+,p1=

45、p1->next) sum+=p1->english; aver=sum/i; p1=head; for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->english) max=(float)p1->english; p1=head; for(i=0;p1!=NULL;i+,p1=p1->next) if(min>p1->english) min=(float)p1->english; printf("english average:%ft",aver); printf("

46、;english max:%ft",max); printf("english min:%fn",min); /*求計算機平均分,最高分和最低分*/void comaverage() stu *p1;int i;float max=0.0,min=100.0;float sum=0.0,aver=0.0;p1=head;if(p1=NULL) printf("not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->computer; aver=sum/i; p1=head

47、; for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->computer) max=(float)p1->computer; p1=head; for(i=0;p1!=NULL;i+,p1=p1->next) if(min>p1->computer) min=(float)p1->computer; printf("computer average:%ft",aver); printf("computer max:%ft",max); printf("computer min:%fn",min);/*通過姓名查找來更新數(shù)據(jù)*/void update(stu *p2) char name10;int b=0;printf("enter name:");scanf("%s",name);while(p2!=NULL)if(strcmp(name,p2->name)=0)printf("find you datan");printf("name:");scanf("%s",p2->name);printf("

溫馨提示

  • 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)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論