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

下載本文檔

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

文檔簡介

1、【學生成績管理】 實現(xiàn)功能:輸入、輸出、插入、刪除、查找、追加、讀入、顯示、保存、拷貝、排序、索引、分類合計、退出。能實現(xiàn)對學生信息的簡單管理。具體要求:建立一個4個學生的信息登記表,每個學生的信息包括:學號,姓名,和3門課程的成績(FOX,C,ENGLISH)。程序運行時顯示一個簡單的菜單,例如: (1):信息輸入(INPUT) (2):總分統(tǒng)計(COUNT) (3):總分排序(SORT) (4):查詢(QUERY) 其中: (1):對4個學生的信息進行輸入; (2):對每個學生的3門課程統(tǒng)計總分; (3):對4個學生的總分按降序排序并顯示出來; (4):查詢輸入一個學號后,顯示出該學生的有

2、關(guān)信息; 用的大一做的系統(tǒng),由保存數(shù)據(jù)結(jié)構(gòu)的object.cpp 主函數(shù) main.cpp 方法頭文件use.h組成Use.h#ifndef USE_H_INCLUDED#define USE_H_INCLUDED#endif / USE_H_INCLUDED#include #include void Meau() printf(-歡迎使用學生信息管理系統(tǒng)-n-n輸入指令完成命令: n1.打印信息n2.插入新信息n3.刪除學生信息n4.查找學生n5.更改學生信息n6.排序顯示學生信息n7.文件另存為ne.保存并退出n-n請輸入指令n);void ZhuangBSave() int T=2;

3、while(T-) system(cls); Meau(); Sleep(500); printf(Saveing.r); Sleep(500); printf(Saveing.r); Sleep(500); printf(Saveing.r); Sleep(500); printf(Saveing.r); Sleep(500); printf(Saveing.r); void ZhuangBExit() int c=6; while(c-) printf(Saved!And he program will be close in %d second.r,c); Sleep(1000); Ob

4、ject.h#include #include #include #include struct score long long num; char a10; int ch; int ma; int en; int c; int ph; int sum; struct score *next;void swap(score* p1,score* p2) int t; t=p1-num; p1-num=p2-num; p2-num=t; t=p1-ch; p1-ch=p2-ch; p2-ch=t; t=p1-ma; p1-ma=p2-ma; p2-ma=t; t=p1-en; p1-en=p2-

5、en; p2-en=t; t=p1-c; p1-c=p2-c; p2-c=t; t=p1-ph; p1-ph=p2-ph; p2-ph=t; char c10; strcpy(c,p1-a); strcpy(p1-a,p2-a); strcpy(p2-a,c);bool cmp0(score* p1,score* p2) return p1-numnum;bool cmp01(score* p1,score* p2) if(p1-ch=p2-ch) return p1-numnum; return p1-chch;bool cmp11(score* p1,score* p2) if(p1-ch

6、=p2-ch) return p1-numnum; return p1-chp2-ch;bool cmp02(score* p1,score* p2) if(p1-ma=p2-ma) return p1-numnum; return p1-mama;bool cmp12(score* p1,score* p2) if(p1-ma=p2-ma) return p1-numnum; return p1-map2-ma;bool cmp03(score* p1,score* p2) if(p1-en=p2-en) return p1-numnum; return p1-enen;bool cmp13

7、(score* p1,score* p2) if(p1-en=p2-en) return p1-numnum; return p1-enp2-en;bool cmp04(score* p1,score* p2) if(p1-c=p2-c) return p1-numnum; return p1-cc;bool cmp14(score* p1,score* p2) if(p1-c=p2-c) return p1-numnum; return p1-cp2-c;bool cmp05(score* p1,score* p2) if(p1-ph=p2-ph) return p1-numnum; ret

8、urn p1-phph;bool cmp15(score* p1,score* p2) if(p1-ph=p2-ph) return p1-numnum; return p1-php2-ph;bool cmp06(score* p1,score* p2) if(p1-sum=p2-sum) return p1-numnum; return p1-sumsum;bool cmp16(score* p1,score* p2) if(p1-sum=p2-sum) return p1-numnum; return p1-sump2-sum;bool cmp07(score* p1,score* p2)

9、 if(strcmp(p1-a,p2-a)=1) return 1; else return 0;bool cmp17(score* p1,score* p2) if(strcmp(p1-a,p2-a)=1) return 0; else return 1;void ScoreSort(struct score *head,bool (*cmp)(score* p1,score* p2) struct score *p1,*p2; for(p1=head; p1!=NULL; p1=p1-next) for(p2=p1-next; p2!=NULL; p2=p2-next) if(*cmp)(

10、p1,p2) swap(p1,p2); void ScorePri(struct score *head) /int c=0; /system(cls); printf(=n); struct score *pri; pri=head; while(pri!=NULL) /printf(test %dn,c+); printf(學號:%I64d 姓名:%sn語文:%d 數(shù)學:%d 英語:%d nc語言:%d 物理:%d n總成績:%d 平均成績:%.2lf n=n,pri-num,pri-a,pri-ch,pri-ma,pri-en,pri-c,pri-ph,pri-sum,pri-sum/5

11、.0); pri=pri-next; printf(Endn);struct score *ScoreIns(struct score *head) struct score *p1,*p2,*newl; newl=(score*)malloc(sizeof(score); printf(請依次輸入學號,語文,數(shù)學,英語,c語言,物理成績n); scanf(%I64d%d%d%d%d%d,&newl-num,&newl-ch,&newl-ma,&newl-en,&newl-c,&newl-ph); newl-sum=newl-ch+newl-ma+newl-en+newl-c+newl-ph;

12、 printf(輸入學生姓名n); scanf(%s,newl-a); if(head=NULL) head=newl; newl-next=NULL; return head; p1=head; p2=p1-next; if(newl-numnum) newl-next=head; return newl; while(p2!=NULL) if(newl-nump1-num&newl-numnum) newl-next=p2; p1-next=newl; break; p1=p2; p2=p1-next; if(p2=NULL) p1-next=newl; newl-next=NULL; r

13、eturn head;void ZhuangBDel() Sleep(500); printf(刪除中.r); Sleep(500); printf(刪除中.r); Sleep(500); printf(刪除中.r); Sleep(500); printf(刪除中.r); Sleep(500); printf(刪除中.r); Sleep(500); printf(已刪除!n);struct score *ScoreDel(struct score *head) struct score *p1,*p2,*h; long long n=0; int flag,flag1=0; int ord;

14、char n1100,s2; flag=0; printf(輸入1學號查詢,輸入2姓名查詢n); scanf(%d,&ord); if(ord=1) printf(請輸入學號n); scanf(%I64d,&n); else if(ord=2) printf(請輸入姓名n); scanf(%s,n1); else printf(Illegal inputn); return head; if(ord=1) printf(您要刪除的學生學號為%I64d,是否刪除?(Y/N),n); scanf(%s,s); if(strcmp(s,Y)!=0) return head; if(ord=2) pr

15、intf(您要刪除的學生姓名為%s,是否刪除?(Y/N),n1); scanf(%s,s); if(strcmp(s,Y)!=0) return head; p1=head; p2=p1-next; if(ord=1&p1-num=n)|(ord=2&strcmp(p1-a,n1)=0) h=p1-next; free(p1); flag=1; ZhuangBDel(); return h; else if(p1-next=NULL) flag1=0; while(flag1!=0&p2-next!=NULL) if(ord=1&p1-num=n)|(ord=2&strcmp(p2-a,n1)

16、=0) p1-next=p2-next; free(p2); flag=1; p1=p2; p2=p1-next; if(flag1!=0&p2-next=NULL) if(ord=1&p1-num=n)|(ord=2&strcmp(p2-a,n1)=0) p1-next=NULL; free(p2); flag=1; if(flag=0|flag1=1) printf(Error:Not Found!n); else ZhuangBDel(); return head;void ScoreSearch(struct score *head) struct score *p1; long lo

17、ng n; int flag; flag=0; printf(輸入需要查找的學號n); scanf(%I64d,&n); for(p1=head; p1!=NULL; p1=p1-next) if(p1-num=n) printf(姓名:%sn語文成績:%dn數(shù)學成績:%dn英語成績:%dnC語言成績:%dn物理成績:%dn總成績:%dn平均成績:%.2lfn,p1-a,p1-ch,p1-ma,p1-en,p1-c,p1-ph,p1-sum,p1-sum/5.0); flag=1; if(flag=0) printf(Error:Not Found!n);void ScoreChange(st

18、ruct score *head) long long m; int n,a; char b100; struct score *p1; printf(請輸入需要修改信息的學號n); scanf(%I64d,&m); for(p1=head; p1!=NULL; p1=p1-next) if(p1-num=m) break; if(p1=NULL) printf(Not Found!n); return; printf(輸入1修改語文成績n輸入2修改數(shù)學成績n輸入3修改英語成績n輸入4修改c語言成績n輸入5修改物理成績n輸入6修改姓名n); scanf(%d,&a); if(a=1) prin

19、tf(該成員語文成績?yōu)?d,請輸入修改值n,p1-ch); scanf(%d,&n); p1-ch=n; printf(修改成功!n); else if(a=2) printf(該成員數(shù)學成績?yōu)?d,請輸入修改值n,p1-ma); scanf(%d,&n); p1-ma=n; printf(修改成功!n); else if(a=3) printf(該成員英語成績?yōu)?d,請輸入修改值n,p1-en); scanf(%d,&n); p1-en=n; printf(修改成功!n); else if(a=4) printf(該成員C語言成績?yōu)?d,請輸入修改值n,p1-c); scanf(%d,&n)

20、; p1-c=n; printf(修改成功!n); else if(a=5) printf(該成員物理成績?yōu)?d,請輸入修改值n,p1-ph); scanf(%d,&n); p1-ph=n; printf(修改成功!n); else if(a=6) printf(該成員姓名為%s,請輸入修改值n,p1-a); scanf(%s,b); strcpy(p1-a,b); printf(修改成功!n); else printf(輸入錯誤,退出修改n);void ScoreView(struct score *head) int a,b; /bool *cmp(score* p1,score* p2)

21、; printf(輸入1按語文成績排列n輸入2按數(shù)學成績排列n輸入3按英語成績排列n輸入4按C語言成績排列n輸入5按物理成績排列n輸入6按總成績排列n輸入7按名字排列n); scanf(%d,&a); printf(輸入0升序排列,輸入1降序排列n); scanf(%d,&b); if(a=1&b=0) ScoreSort(head,&cmp01); if(a=1&b=1) ScoreSort(head,cmp11); if(a=2&b=0) ScoreSort(head,cmp02); if(a=2&b=1) ScoreSort(head,cmp12); if(a=3&b=0) ScoreS

22、ort(head,cmp03); if(a=3&b=1) ScoreSort(head,cmp13); if(a=4&b=0) ScoreSort(head,cmp04); if(a=4&b=1) ScoreSort(head,cmp14); if(a=5&b=0) ScoreSort(head,cmp05); if(a=6&b=0) ScoreSort(head,cmp06); if(a=6&b=1) ScoreSort(head,cmp16); if(a=7&b=0) ScoreSort(head,cmp07); if(a=7&b=1) ScoreSort(head,cmp17); Sco

23、rePri(head); ScoreSort(head,cmp0);void Save(score *head,char a) FILE *fp; score* pri=head; fp=fopen(a,w); while(pri!=NULL) fprintf(fp,%I64d %d %d %d %d %d ,pri-num,pri-ch,pri-ma,pri-en,pri-c,pri-ph); fprintf(fp,%s ,pri-a); pri=pri-next; return;void NSave(score* head) char a100,b100,c=/,d=.txt; print

24、f(輸入另存為的地址n); scanf(%s,a); printf(輸入文件名稱n); scanf(%s,b); strcat(a,c); strcat(a,b); strcat(a,d); Save(head,a); return;struct score *Load(score *head) /int c=0; FILE *fp; fp=fopen(E:data.txt,r); if(fp=NULL) /printf(No datan); return NULL; freopen(E:data.txt,r,stdin); score *newl,*p1,*p2; newl=(score*)

25、malloc(sizeof(score); while(scanf(%I64d%d%d%d%d%d,&newl-num,&newl-ch,&newl-ma,&newl-en,&newl-c,&newl-ph)!=EOF) /printf(test %dn,c+); newl-sum=newl-ch+newl-ma+newl-en+newl-c+newl-ph; scanf(%s,newl-a); if(head=NULL) head=newl; newl-next=NULL; p1=head; p2=p1-next; if(newl-numnum) newl-next=head; head=n

26、ewl; while(p2!=NULL) if(newl-nump1-num&newl-numnum) newl-next=p2; p1-next=newl; p1=p2; p2=p1-next; if(p2=NULL) p1-next=newl; newl-next=NULL; newl=(score*)malloc(sizeof(score); free(newl); freopen(CON,r,stdin); return head;Main.cpp#include #include #include #include #include #include #include use.hus

27、ing namespace std;struct score *Load(score *head);void ScorePri(struct score *head);struct score *ScoreIns(struct score *head);struct score *ScoreDel(struct score *head);void ScoreSearch(struct score *head);void ScoreChange(struct score *head);void ScoreView(struct score *head);void Save(score *head,char

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 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

提交評論