vc學生信息管理系統(tǒng)教學內容_第1頁
vc學生信息管理系統(tǒng)教學內容_第2頁
vc學生信息管理系統(tǒng)教學內容_第3頁
vc學生信息管理系統(tǒng)教學內容_第4頁
vc學生信息管理系統(tǒng)教學內容_第5頁
已閱讀5頁,還剩58頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、Good is good, but better carries it.精益求精,善益求善。vc學生信息管理系統(tǒng)-vc學生信息管理系統(tǒng)懸賞分:0-解決時間:2008-6-1116:461)能夠從屏幕上讀取一個學生的信息并將信息存入到數據文件中。2)能夠將指定的信息從文件中刪除。3)能夠按編號、姓名對學生的信息進行檢索并將檢索結果顯示在屏幕上。4)可以統(tǒng)計全部學生的總成績,及其在班上的排名。5)能夠統(tǒng)計各科的平均成績及及格率。6)要求有錯誤提示功能,例如性別只能輸入男女,輸入錯誤提示重新輸入。7)如果檢索不到相應的信息應提示用戶。#include#include#include#include#

2、include#include#include#include#include/#defineNULL0intconstQ=20;#defineLENsizeof(structstudent)usingnamespacestd;intn=0;/定義一個全局變量統(tǒng)計學生人數/-定義一個學生考試信息的結構體structstudentcharnameQ;/用來存放姓名的charsexQ;/用來存放性別的longintid;/用來存放準考證號的intscore4;/用來存放分數的inttotal;/用來存放總分數的structstudent*next;/student向量容器vectorstu;/-學

3、生類classInformationpublic:Information();/構造函數.Information();/析構函數.student*creat();/建立鏈表函數。voidoutput(student*head);intcount(student*head);/定義函數count()統(tǒng)計考生總數student*insert(student*head);/指針函數*insert()用來添加考生信息.student*cancel(student*head,longintnum);/指針函數*cancel()用來刪除考生信息.student*find(student*head,long

4、intnum);/指針函數*find()用來查找考生信息.voidinorder(student*head);/定義inorder()函數將考生的總分從大到小排列并輸出voidaverage(student*head);/求學生成績的平均分的函數voidsave(student*head);/保存函數student*Read();/讀取函數private:student*p1,*p2,*p3,*head,st;Information:Information()cout*n;cout-n;cout*nn;Information:Information()cout*n;cout-n;cout*n;

5、student*Information:creat(void)/定義一個指向structstudent的結構體指針函數*creat()用來增加考生信息.charchQ;n=0;/用來存放姓名的p1=p2=(student*)malloc(LEN);/調用malloc()函數用來開辟一個新的存儲單元cout-endl;coutch;head=NULL;/給指針head賦初值while(strcmp(ch,!)!=0)/調用字符比較函數strcmp()用來判斷是否繼續(xù)輸入charstr10;intflag=0;p1=(student*)malloc(LEN);/調用malloc()函數用來開辟一個

6、新的存儲單元strcpy(p1-name,ch);/將循環(huán)結構前面輸入的姓名復制到結構體名為p1的數組name中coutp1-sex;coutstr;if(atol(str)99999999|atol(str)1)coutid=atol(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore0=atoi(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore1=atoi(str);flag=1;w

7、hile(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore2=atoi(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore3=atoi(str);flag=1;while(flag=0);flag=0;p1-total=p1-score0+p1-score1+p1-score2+p1-score3;/計算總分if(n=0)head=p1;/如果是輸入第一組學生考試信息就將指針p1賦給指針headelsep2-next=p1

8、;/否則將p1賦給p2所指結構體的next指針p2=p1;/將指針p1賦給指針p2n+;/將n的值加1coutch;/將輸入的姓名存放到字符數組ch中p2-next=NULL;/將p2所指結構體的next指針重新賦空值return(head);/將輸入的第一組學生考試信息返回/-定義output()函數將考生的信息從頭指針所指內容開始輸出voidInformation:output(student*head)if(head=NULL)cout這是一個空表,請先輸入考生成績.n;elsecout-n;cout*學生考試成績信息表*n;cout-n;cout準考證號姓名性別計算機組成原理概率統(tǒng)計英

9、語C+平均分總分n;cout-n;p1=head;/將頭指針賦給pdocoutsetw(8)idsetw(9)namesetw(8)sexsetw(13)score0setw(16)score1setw(10)score2setw(9)score3setw(6)total/4.0setw(11)totalendl;coutnext;/將下一組考生信息的next指針賦給pwhile(p1!=NULL);/若指針p非空則繼續(xù),目的是把所有的考生信息都傳給指針p然后輸出./-統(tǒng)計學生人數的函數intInformation:count(structstudent*head)/定義函數count()統(tǒng)計

10、考生總數if(head=NULL)return(0);/若指針head為空返回值為0elsereturn(1+count(head-next);/函數的遞歸調用/-插入學生的成績的函數student*Information:insert(student*head)/插入新結點定義一個指向structstudent的結構體指針函數*insert()用來添加考生信息.charstr10;intflag=0;coutt-nendl;p1=(student*)malloc(LEN);/使p1指向插入的新結點coutp1-name;/將輸入的姓名存放到結構體名為p1的數組name中coutp1-sex;

11、coutstr;if(atol(str)99999999|atol(str)1)coutid=atol(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore0=atoi(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore1=atoi(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore2=a

12、toi(str);flag=1;while(flag=0);flag=0;coutstr;if(atoi(str)100|atoi(str)1)coutscore3=atoi(str);flag=1;while(flag=0);flag=0;p1-total=p1-score0+p1-score1+p1-score2+p1-score3;/計算總分p2=head;/將頭指針賦給p2if(head=NULL)/若沒調用次函數以前的頭指針head為空head=p1;p1-next=NULL;/則將p1賦給頭指針head并將p1所指結構體成員指針next賦空值elsewhile(p1-idp2-id

13、)&(p2-next!=NULL)p3=p2;/p3指向原p2指向的結點p2=p2-next;/p2后移一個結點if(p1-idid)if(head=p2)p1-next=head;head=p1;/插入到第一個結點之前elsep3-next=p1;p1-next=p2;/插入到p3所指結點之后elsep2-next=p1;p1-next=NULL;/插入到尾結點之后n+;/將學生人數加1coutt你輸入的學生信息已經成功插入刪除函數student*Information:cancel(student*head,longintnum)/定義一個指向structstudent的結構體指針函數*d

14、elete()用來刪除考生信息.if(head=NULL)/若調用次函數以前的頭指針head為空return(head);elsep1=head;/否則將頭指針賦給p1while(num!=p1-id&p1-next!=NULL)/尋找要刪除的結點當p1所指的學生準考證號不是輸入的學生準考證號并且p1所指的next指針不為空p2=p1;p1=p1-next;/p2指向原p1指向的結點p1后移一個結點if(num=p1-id)/如果輸入的學生準考證號是p1所指的學生準考證號/結點找到后刪除if(p1=head)head=p1-next;/如果head指針和p1指針相等則將下一個結點賦給指針hea

15、delsep2-next=p1-next;/否則將p1所指結點賦給p2所指結點將要刪除的學生信息跳過去cout刪除準考證號為num查找函數student*Information:find(student*head,longintnum)/定義一個指向structstudent的結構體指針函數*find()用來查找考生信息.if(head=NULL)/若調用次函數以前的頭指針head為空coutid&p1-next!=NULL)/尋找結點當p1所指的學生準考證號不是輸入的學生準考證號并且p1所指的next指針不為空p1=p1-next;/p2指向原p1指向的結點p1后移一個結點if(num=p1

16、-id)/如果要查找的學生準考證號是p1所指的學生準考證號cout-n;cout準考證號姓名性別計算機組成原理概率統(tǒng)計英語C+平均分總分n;cout-n;coutsetw(8)idsetw(9)namesetw(8)sexsetw(13)score0setw(16)score1setw(10)score2setw(9)score3setw(6)total/4.0setw(11)totalendl;cout-n;elsecout沒找到準考證號為num的學生.n;/結點沒找到return(head);/-定義inorder()函數將考生的總分從大到小排列并輸出voidInformation:ino

17、rder(student*head)inti,k,m=0,j;student*pQ;/定義一個指向structstudent的結構體指針數組pif(head!=NULL)/如果頭指針是空則繼續(xù)m=count(head);cout-n;cout學生考試成績統(tǒng)計表n;cout-n;cout準考證號姓名性別計算機組成原理概率統(tǒng)計英語C+平均分總分名次n;cout-n;p1=head;for(k=0;knext;for(k=0;km-1;k+)/選擇排序法for(j=k+1;jtotaltotal)p2=pk;pk=pj;pj=p2;/從大到小排列的指針for(i=0;im;i+)coutsetw(8

18、)idsetw(9)namesetw(8)sexsetw(13)score0setw(16)score1setw(10)score2setw(9)score3setw(6)total/4.0setw(11)totalendl;cout求各科平均分成績的函數voidInformation:average(student*head)intk,m;floatarg1=0,arg2=0,arg3=0,arg4=0;if(head=NULL)/如果頭指針是空則繼續(xù)cout這是一個空表,請先輸入考生成績.n;elsem=count(head);p1=head;for(k=0;kscore0;arg2+=p

19、1-score1;arg3+=p1-score2;arg4+=p1-score3;p1=p1-next;arg1/=m;arg2/=m;arg3/=m;arg4/=m;cout全班單科成績平均分n;cout-n;cout計算機組成原理平均分:setw(7)arg1概率統(tǒng)計平均分:setw(7)arg2英語平均分:setw(7)arg3C+平均分:setw(7)arg4endl;cout保存函數.voidInformation:save(student*head)ofstreamout(data.txt,ios:out);outcount(head)endl;while(head!=NULL)o

20、utnametidttsextscore0tscore1tscore2tscore3ttotalnext;/讀取函數的實現student*Information:Read()inti=0;p1=p2=(student*)malloc(LEN);head=NULL;ifstreamin(data.txt,ios:out);ini;if(i=0)coutdata.txt文件中的數據為空,請先輸入數據。endl;return0;elsecout0;i-)p1=(student*)malloc(LEN);cinst.idst.sexst.score0st.score1st.score2st.score

21、3st.total;strcpy(p1-name,);p1-id=st.id;strcpy(p1-sex,st.sex);p1-score0=st.score0;p1-score1=st.score1;p1-score2=st.score2;p1-score3=st.score3;p1-total=st.total;if(n=0)head=p1;/如果是輸入第一組學生考試信息就將指針p1賦給指針headelsep2-next=p1;/否則將p1賦給p2所指結構體的next指針p2=p1;/將指針p1賦給指針p2n+;/將n的值加1/顯示讀入數據coutnametidttsextscore0ts

22、core1tscore2tscore3ttotalendl;coutendl;/cout數據已經成功讀取完畢。next=NULL;return(head);/-主函數.intmain(void)Informationperson;student*head=NULL;charstr10;intflag=0;intchoice;longinti;head=person.Read();docoutendl;cout學生成績管理系統(tǒng)主菜單界面endl;cout讀取數據請輸入數字零endl;coutendl;cout.輸入學生成績endl;cout.顯示學生成績endl;cout.排序統(tǒng)計成績endl;

23、cout.查找學生成績endl;cout.增加學生成績endl;cout.刪除學生成績endl;cout.保存退出系統(tǒng)endl;coutendl;coutstr;if(atoi(str)7|atoi(str)1)cout對不起,請輸入1-7這幾個數字!n;elsechoice=atoi(str);switch(choice)case1:head=person.creat();break;case2:person.output(head);break;case3:person.inorder(head);person.average(head);cout參加考試的學生人數為:person.cou

24、nt(head)人n;break;case4:coutstr;if(atol(str)99999999|atol(str)1)cout對不起,請輸入正確輸入!n;elsei=atol(str);flag=1;while(flag=0);flag=0;person.find(head,i);break;case5:head=person.insert(head);person.output(head);break;case6:coutstr;if(atol(str)99999999|atol(str)1)cout對不起,請輸入正確輸入!hn;elsei=atol(str);flag=1;whil

25、e(flag=0);flag=0;head=person.cancel(head,i);person.output(head);break;case7:person.save(head);cout文件已保存!可以安全退出!endl;break;default:cout相關內容HYPERLINK/question/152102420.html?fr=qrl&cid=866&index=1&fr2=queryt_blank求畢業(yè)論文VC“學生信息管理系統(tǒng)”2010-5-25HYPERLINK/question/47128238.html?fr=qrl&cid=866&index=2&fr2=que

26、ryt_blank用VC+做“學生信息管理系統(tǒng)”的登錄界面32008-3-19HYPERLINK/question/53288779.html?fr=qrl&cid=866&index=3&fr2=queryt_blank誰能幫我vc+做個學生信息管理系統(tǒng)52008-5-29HYPERLINK/question/58880756.html?fr=qrl&cid=866&index=4&fr2=queryt_blank用VC編寫一個學生信息管理系統(tǒng)2008-7-5HYPERLINK/question/163679654.html?fr=qrl&cid=866&index=5&fr2=queryt

27、_blank誰能提供一下用VC+制作一個學生信息管理系統(tǒng)的代碼的啊?12010-7-4HYPERLINK/q?word=vc%20%D1%A7%C9%FA%B9%DC%C0%ED%CF%B5%CD%B3&ct=17&pn=0&tn=ikaslist&rn=10&fr=qrl&cid=866&fr2=queryt_blank更多關于vc學生管理系統(tǒng)的問題查看同主題問題:HYPERLINK/topic?ct=29&tn=iktopic&word=%D1%A7%C9%FA%D0%C5%CF%A2%B9%DC%C0%ED%CF%B5%CD%B3&fr=rtag&cid=866&index=1&fr2=

28、queryt_blank學生信息管理系統(tǒng)等待您來回答HYPERLINK/q?ct=18&tn=ikqlall_cookie&lm=2更多0回答HYPERLINK/question/198390515.html?push=qlo誰有易學C+這本書的電子版幫忙發(fā)帶407066663t_blank誰有易學C+這本書的電子版幫忙發(fā)帶4070666630回答20HYPERLINK/question/198390365.html?push=qloLinuxwindowssocket傳輸問題t_blankLinuxwindowssocket傳輸問題0回答HYPERLINK/question/19839007

29、3.html?push=qloC+簡單問題,謝謝。t_blankC+簡單問題,謝謝。0回答HYPERLINK/question/198389926.html?push=qlo蘋果電腦YY語音的聲卡驅動在哪里?QQ757066637t_blank蘋果電腦YY語音的聲卡驅動在哪里?QQ7570666370回答HYPERLINK/question/198389442.html?push=qlo榮成方正房地產公司開發(fā)的寶月山莊怎么樣t_blank榮成方正房地產公司開發(fā)的寶月山莊怎么樣0回答HYPERLINK/question/198389429.html?push=qloc語言中(a)(b)?(a):

30、(b)什么意思t_blankc語言中(a)(b)?(a):(b)什么意思0回答HYPERLINK/question/198389071.html?push=qlo急!在線等!t_blank急!在線等!0回答HYPERLINK/question/198388980.html?push=qlo屢敗屢戰(zhàn)說明了什么道理t_blank屢敗屢戰(zhàn)說明了什么道理其他回答共1條#include#include#includestructstudlongnum;charname20;doublescore;typedefstructstucodestructstudstudent;structstucode*ne

31、xt;L;voidmenu();voidcreatelist(structstucode*r);voidout(structstucode*r);voidsearch1(structstucode*r);voidsearch2(structstucode*r);voiddel(structstucode*r);voidinsert(structstucode*r);voidsort(structstucode*r);voidmain()charchoose;intflag=1;structstucode*r=NULL;while(flag)system(cls);menu();choose=g

32、etchar();switch(choose)case1:createlist(&r);out(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar();break;case2:search1(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar();break;case3:search2(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar()

33、;break;case4:del(&r);out(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar();break;case5:insert(&r);out(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar();break;case6:sort(&r);out(r);printf(Testingfunction1nPressanykeytocontinuen);getchar();getchar();break;case

34、7:out(r);printf(Testingfunction7nPressanykeytocontinuen);getchar();getchar();break;case0:flag=0;printf(Theend.n);break;default:printf(nWrongSelection!(選擇錯誤,請重選!)n);getchar();getchar();voidcreatelist(structstucode*r)structstucode*p,*t;longn;chara20;doubles;if(*r)*r=NULL;printf(n請輸入:n學號(請按學號升序排列)姓名分數(

35、若要結束請輸入三個為零)n);scanf(%ld%s%lf,&n,a,&s);if(n=0)return;p=(L*)malloc(sizeof(L);p-student.num=n;strcpy(p-,a);p-student.score=s;p-next=NULL;*r=p;scanf(%ld%s%lf,&n,a,&s);while(n)t=p;p=(L*)malloc(sizeof(L);p-student.num=n;strcpy(p-,a);p-student.score=s;p-next=NULL;t-next=p;scanf(%ld%s%lf,&n,a,&s);voidsearc

36、h1(structstucode*r)longx;if(!r)printf(沒有學生信息可查詢!n);return;printf(請輸入要查詢的學生信息的學生學號:n);scanf(%ld,&x);while(r&r-student.num!=x)r=r-next;if(r=NULL)printf(Error!Nosuchstudent!n);elseprintf(%ld%s%.2lfn,r-student.num,r-,r-student.score);voidsearch2(structstucode*r)charm20;if(!r)printf(沒有學生信息可查詢!n);return;printf(請輸入要查詢的學生信息的學生姓名:n);scanf(%s,m);while(r&strcmp(r-,m)r=r-next;if(r=NULL)printf(Error!Nosuchstudent!n);elseprintf(%ld%s%.2lfn,r-student.num,r-,r-student.score);voiddel(structstucode*r)longk;structstucode*p=*r,*t;if(!(*r)printf(沒有學生信息可刪除!n);return;printf(請輸入要

溫馨提示

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

評論

0/150

提交評論