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

下載本文檔

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

文檔簡介

1、#include<iostream> #include<fstream> #include<string> #include <iomanip> #include<windows.h> #include<ctime> using namespace std; const int NAME_NUM=30; struct student char  nameNAME_NUM;     float n

2、um; float chinaNum;  float englishNum; float mathNum; float average; float result; int   pos; student *next; ; void Print(student *head);     void InsertFront(student* &head, student *pNew); void&

3、#160;InsertRear(student* &head, student *pNew); student* Find(student *head, char *findStr, char type); student* Read(); void Write(student* head); void ShowList(student* head); int GetLength(student* head); void

4、0;Delete(student* &head, char *delStr,int delNum); void FindMaxOrMin(student *head,char type,char maxOrMin); void Reword(student *pStd); void Sort(student *&head, char type,char maxOrMin); void Count(student 

5、;*&head); void DeleteAll(student *&head); bool Enter(char type); void SetTitle(bool isLoad); void AboutMe(); void ChaXun(string str,student *head); void PaiMing(string str, student* head); void ShanChu(string str

6、, student *&head); void XianShi(string str, student *head); void XuiGai(string str, student *&head); void ZengJia(string str, student* &head); int Run(); bool Enter(char type) ofstream out("Pas

7、sword.pwd",ios:app); ifstream in("Password.pwd");      string s2; int num=0; string zhangHao; string miMa; while(!in.eof() in>>snum; num+; if(num=2) break; if(pare("")=0 | type='2' ) if(par

8、e("")=0 && type!='2') cout<<"你是第一次使用本程序,請設(shè)置帳號和密碼."<<endl; else bool isLoad=false; isLoad=Enter('1'); if(isLoad=true) cout<<"修改用戶."<<endl; out.close(); out.open("Password.pwd",ios:trunc); else cout&

9、lt;<"你輸入的密碼錯誤."<<endl; cout<<"你不是管理員不能修改密碼."<<endl;                 return false; cout<<"請輸入您的新帳號: " cin>>s0; cout<<"請輸入您的新密碼: &quo

10、t; cin>>s1; string s1,s2; for(int i=0; i<s0.size(); i+) s1+=char(int(s0i)+11); for( i=0; i<s1.size(); i+) s2+=char(int(s1i)+11); s0=s1; s1=s2; for( i=0; i<=1; i+) out<<si<<" " out.close();    &

11、#160;string s1,s2; for(int i=0; i<s0.size(); i+) s1+=char(int(s0i)-11); for( i=0; i<s1.size(); i+) s2+=char(int(s1i)-11); cout<<"請輸入您的帳號: " cin>>zhangHao;     cout<<"請輸入您的密碼: "   &#

12、160; cin>>miMa; if(zhangHpare(s1)=0 && miMpare(s2)=0) return true; else return false; return false; void Print(student *head) student *pHead=head; int num=strlen(head->name); while(head) if(num<strlen(head->name) num=strlen(hea

13、d->name); head=head->next; head=pHead; cout<<setw(num)<<head->name<<setw(8) <<head->num<<setw(10)<<head->chinaNum <<setw(10)<<head->mathNum<<setw(10) <<head->englishNum<<setw(8)<<head->result <<setw

14、(8)<<head->average<<setw(5)<<head->pos<<endl;  void ShowList(student* head) cout<<"姓名:"<<setw(8)<<"座號:"<<setw(10) <<"語文分?jǐn)?shù):"<<setw(10) <<"數(shù)學(xué)分?jǐn)?shù):" <<setw(10)<<

15、"英語分?jǐn)?shù):"<<setw(8)<<"總分?jǐn)?shù):" <<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl;  while(head) Count(head); Print(head); head=head->next; cout<<endl; void Write(student* head) ofstream out(&quo

16、t;Student.dat",ios:trunc); while(head) Count(head); out.write(char*)head,sizeof(student); head=head->next; out.close(); student* Read() ifstream in("Student.dat"); student *head; student *pP; student *pEnd; pP=new student; pEnd=head=pP; student *p

17、S=new student; memset(pS->name,0,NAME_NUM); in.read(char*)pS,sizeof(student); if(strcmp(pS->name,"0")=0) return NULL;     strcpy(pP->name,pS->name);    pP->num=pS->num;          

18、;        pP->chinaNum=pS->chinaNum;     pP->englishNum=pS->englishNum; pP->mathNum=pS->mathNum; while(!in.eof() in.read(char*)pS,sizeof(student); pEnd->next=pP; pEnd=pP; pP=new student; strcpy(pP->name,pS->name);&

19、#160;   pP->num=pS->num;              pP->chinaNum=pS->chinaNum; pP->englishNum=pS->englishNum; pP->mathNum=pS->mathNum; pEnd->next=NULL; delete pP; return head;    student*

20、 Find(student *head,char *findStr, char type) /*參數(shù)說明:  type='1' 按 名字   查找  type='2' 按 座號   查找  type='3' 按 語文   查找  type='4' 按 數(shù)學(xué) 

21、0; 查找 type='5' 按 英語   查找 type='6' 按 總分   查找 type='7' 按 平均分 查找 type='8' 按 排名   查找  /沒有實現(xiàn)   */     bool isFind=false; student 

22、;*firstStd=NULL;      cout<<"姓名:"<<setw(8)<<"座號:"<<setw(10) <<"語文分?jǐn)?shù):"<<setw(10) <<"數(shù)學(xué)分?jǐn)?shù):" <<setw(10)<<"英語分?jǐn)?shù):"<<setw(8)<<"總分?jǐn)?shù):" <<setw(8)<<

23、;"平均分:"<<setw(5)<<"名次:"<<endl<<endl;  while(head) if(type='1') if(strcmp(head->name,findStr)=0)   if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(typ

24、e='2')             if(int(head->num)=int(atof(findStr)   if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='3')   

25、60;         if(int(head->chinaNum)=int(atof(findStr)  if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='4')        

26、0;    if(int(head->mathNum)=int(atof(findStr)  if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='5')             if(int

27、(head->englishNum)=int(atof(findStr)   if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='6')             if(int(head->result)=int(a

28、tof(findStr)   if(firstStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='7')             if(int(head->average)=int(atof(findStr)  if(firs

29、tStd=NULL) firstStd=head; Print(head); isFind=true;   if(head->next=NULL) return firstStd; else if(type='8')             if(int(head->pos)=int(atof(findStr)    if(firstStd=NULL) firstStd=head

30、; Print(head); isFind=true;   if(head->next=NULL) return firstStd; head=head->next;     if(isFind=false) cout<<"找不到你要找的記錄."<<endl; return NULL; return firstStd; void InsertRear(student* &head,student *pNew) s

31、tudent *pEnd,*pHead,*pS=new student; if(head=NULL) InsertFront(head,pNew); return  pHead=head; while(head) pEnd=head; if(head->next=NULL) break; head=head->next;     strcpy(pS->name,pNew->name);  pS->num=pNew->num;    

32、0;       pS->chinaNum=pNew->chinaNum;     pS->englishNum=pNew->englishNum; pS->mathNum=pNew->mathNum;     pS->next=NULL; pEnd->next=pS; head=pHead; void InsertFront(student* &head, studen

33、t *pNew) student *pHead=new student; strcpy(pHead->name,pNew->name);   pHead->num=pNew->num;          pHead->chinaNum=pNew->chinaNum;     pHead->englishNum=pNew->englishNum; pHead->ma

34、thNum=pNew->mathNum; pHead->next=head; head=pHead; int GetLength(student *head) int len=0; while(head) len+; head=head->next; return len; void Delete(student* &head, char *delStr,int delNum) student* pDel,*pNew,*pHead;    

35、 bool isFind=false; pHead=head; if(strcmp(head->name,delStr)=0) pNew=head->next; delete head; head=pNew; if(delNum=2) cout<<endl<<"因為要刪除的記錄在前面,所有只刪除第一記錄."<<endl; return  while(head->next) if(delNum=2) if(strcmp(head->next->name,delStr)=0

36、) pNew=head->next->next; pDel=head->next; delete pDel; head->next=pNew; head=pHead; isFind=true;          else if(strcmp(head->next->name,delStr)=0) pNew=head->next->next; pDel=head->next; delete pDel; head->next=pNew; h

37、ead=pHead; return  head=head->next;     head=pHead; if(isFind=false) cout<<"找不到你要刪除的記錄."<<endl; else cout<<"刪除記錄成功."<<endl; void FindMaxOrMin(student *head,char type,char maxOrMin) /*參數(shù)說明:  type='1&#

38、39; 按 語文   查找  type='2' 按 數(shù)學(xué)   查找 type='3' 按 英語   查找 type='4' 按 總分   查找 type='5' 按 平均分 查找 type='6' 按 排名   查找 &

39、#160;  */ int maxNum; student *pHead=head; if(type='1') maxNum=int(head->chinaNum); else if (type='2') maxNum=int(head->mathNum); else if (type='3') maxNum=int(head->englishNum); else if (type='4') maxNum=int(head-

40、>result); else if (type='5') maxNum=int(head->average); else if (type='6') maxNum=head->pos; else  cout<<"你輸入錯誤,請重新輸入."<<endl; return  while(head) if(maxOrMin='1') if(type='1') if(maxNum<int(head->chin

41、aNum) maxNum=int(head->chinaNum); else if (type='2') if(maxNum<int(head->mathNum) maxNum=int(head->mathNum); else if (type='3') if(maxNum<int(head->englishNum) maxNum=int(head->englishNum); else if (type='4') if(maxNum<int

42、(head->result) maxNum=int(head->result); else if (type='5') if(maxNum<int(head->average) maxNum=int(head->average); else if (type='6') if(maxNum<head->pos) maxNum=head->pos; else if(type='1') if(maxNum>int(head->chinaNum) maxN

43、um=int(head->chinaNum); else if (type='2') if(maxNum>int(head->mathNum) maxNum=int(head->mathNum); else if (type='3') if(maxNum>int(head->englishNum) maxNum=int(head->englishNum); else if (type='4') if(maxNum>int(head->

44、result) maxNum=int(head->result); else if (type='5') if(maxNum>int(head->average) maxNum=int(head->average); else if (type='6') if(maxNum>head->pos) maxNum=head->pos; head=head->next;     head=pHead; cout<<"姓名

45、:"<<setw(8)<<"座號:"<<setw(10) <<"語文分?jǐn)?shù):"<<setw(10) <<"數(shù)學(xué)分?jǐn)?shù):" <<setw(10)<<"英語分?jǐn)?shù):"<<setw(8)<<"總分?jǐn)?shù):" <<setw(8)<<"平均分:"<<setw(5)<<"名次:"<<

46、;endl<<endl;  while(head) if(type='1') if(int(head->chinaNum)=maxNum) Print(head); else if (type='2') if(int(head->mathNum)=maxNum) Print(head); else if (type='3') if(int(head->englishNum)=maxNum) Print(head); else if (type=&#

47、39;4') if(int(head->result)=maxNum) Print(head); else if (type='5') if(int(head->average)=maxNum) Print(head); else if (type='6') if(head->pos=maxNum) Print(head); head=head->next; void Reword(student *pStd) if(pStd!=NULL) cout<<&qu

48、ot;請輸入學(xué)生的新名字:"<<endl; cin>>pStd->name; cout<<"請輸入學(xué)生的座號"<<endl; cin>>pStd->num; cout<<"請輸入學(xué)生的語文分?jǐn)?shù)"<<endl; cin>>pStd->chinaNum; cout<<"請輸入學(xué)生的數(shù)學(xué)分?jǐn)?shù)"<<endl; cin>>pStd->mathNum; cout<<&qu

49、ot;請輸入學(xué)生的英語分?jǐn)?shù)"<<endl; cin>>pStd->englishNum;      else return    void Sort(student *&head, char type,char maxOrMin)   /*參數(shù)說明:  type='1' 按 語文   排列  type='2' 按

50、60;數(shù)學(xué)   排列 type='3' 按 英語   排列 type='4' 按 總分   排列 type='5' 按 平均分 排列 type='6' 按 座號   排列    */ student *pHead,*pH;     pHead=p

51、H=head; int len=GetLength(head);     float *array=new floatlen; int i; int x=0; float num=0; while(head)   Count(head); if(type='1')   num=head->chinaNum; else if(type='2')   num=head->mathNum; else if(t

52、ype='3') num=head->englishNum; else if(type='4') num=head->result; else if(type='5') num=head->average; else if(type='6') num=head->num; arrayx=num; x+; head=head->next; head=pHead; if(maxOrMin='1') for( i=1; i<len;&#

53、160;i+) for(int j=0; j<len-i; j+) if(arrayj<arrayj+1) float num; num=arrayj; arrayj=arrayj+1; arrayj+1=num;      else  for( i=1; i<len; i+) for(int j=0; j<len-i; j+) if(arrayj>arrayj+1) float num; num=arra

54、yj; arrayj=arrayj+1; arrayj+1=num; int pos=1; for(i=0; i<len; i+) head=pHead; while(head)   if(type='1') num=head->chinaNum; else if(type='2') num=head->mathNum; else if(type='3') num=head->englishNum; else if(type='4') n

55、um=int(head->result); else if(type='5') num=int(head->average); else if(type='6') num=int(head->num); int n=0; if(int(arrayi)=int(num)    if(int(arrayi)!=int(arrayi+1)         if(n=0)    n=pos;   

56、0;   head->pos=pos; pos+;      else    head->pos=n;   head=head->next; head=pH; delete array; void Count(student *&head) head->result=head->chinaNum+head->englishNum+head->mathNum; head->average=head->res

57、ult/3; void DeleteAll(student* &head) student *cp,*np;     cp=head; while(cp)        np=cp->next;    delete cp;    cp=np; head=NULL; void ChaXun(string str,student *head) So

58、rt(head,'4','1'); cout<<"歡迎使用查詢功能"<<endl<<endl; cout<<"請輸入你要按什么查詢    1->一般查詢     2->查找最多    3->查找最少"<<endl; string s; cin>>s; while(s0!='1'&a

59、mp;&s0!='2'&&s0!='3') cout<<"你輸入錯誤,請重新輸入."<<endl; cin>>s; if(s0='1') cout<<"按什么查詢?"<<endl; cout<<"1->姓名 2->座號 3->語文成績 4->數(shù)學(xué)成績 " <<"5->英語成績 6->總分

60、 7->平均分 8->排名"<<endl; cin>>str; while(str0!='1' && str0!='2' && str0!='3' && str0!='4' && str0!='5' && str0!='6' && str0!='

61、;7' && str0!='8' ) cout<<"你輸入錯誤,請重新輸入."<<endl; cin>>str; char findStr30; cout<<"請輸入要查找的關(guān)鍵字或關(guān)鍵數(shù):"<<endl; cin>>findStr; switch(str0) case '1': Find(head,findStr,'1'); break; case &

62、#39;2': Find(head,findStr,'2'); break; case '3': Find(head,findStr,'3'); break; case '4': Find(head,findStr,'4'); break; case '5': Find(head,findStr,'5'); break; case '6': Find(head,findStr,'6'); break; c

63、ase '7': Find(head,findStr,'7'); break; case '8': Find(head,findStr,'8'); break; else if(s0='2') cout<<"請輸入要按什么查詢?"<<endl; cout<<"1->語文成績 2->數(shù)學(xué)成績 " <<"3->英語成績 4->總分 

64、;5->平均分 6->排名"<<endl; string s; cin>>s; switch(s0) case '1': FindMaxOrMin(head,'1','1'); break; case '2': FindMaxOrMin(head,'2','1'); break; case '3': FindMaxOrMin(head,'3','1'); b

65、reak; case '6': FindMaxOrMin(head,'6','1'); break;         case '5': FindMaxOrMin(head,'5','1'); break; default: FindMaxOrMin(head,'4','1'); break; else if(s0='3') cout<&

66、lt;"請輸入要按什么查詢?"<<endl; cout<<"1->語文成績 2->數(shù)學(xué)成績 " <<"3->英語成績 4->總分 5->平均分 6->排名"<<endl; string s; cin>>s; switch(s0) case '1': FindMaxOrMin(head,'1','2'); break; cas

67、e '2': FindMaxOrMin(head,'2','2'); break; case '3': FindMaxOrMin(head,'3','2'); break; case '6': FindMaxOrMin(head,'6','2'); break; case '5': FindMaxOrMin(head,'5','2'); break; default

68、: FindMaxOrMin(head,'4','2'); break; void ZengJia(string str, student* &head) student *pNew=new student; cout<<"歡迎使用增加功能"<<endl<<endl; cout<<"請輸入新學(xué)生的名字 :"<<endl; cin>>pNew->name; cout<

69、;<"請輸入新學(xué)生的座號 :"<<endl; cin>>pNew->num; cout<<"請輸入他的語文分?jǐn)?shù) :"<<endl; cin>>pNew->chinaNum; cout<<"請輸入他的數(shù)學(xué)分?jǐn)?shù)"<<endl; cin>>pNew->mathNum; cout<<"請輸入他的英語分?jǐn)?shù)"<<endl; cin>>pNew->e

70、nglishNum; cout<<"插入記錄的 (1->最前面  2->最后面)"<<endl; cin>>str; while(str0!='1' && str0!='2') cout<<"你輸入錯誤,請重新輸入."<<endl; cout<<"插入記錄的 (1->最前面  2->最后面)"<<end

71、l; cin>>str; if(str0='1') InsertFront(head,pNew); else if(str0='2') InsertRear(head,pNew); cout<<"新學(xué)生增加成功."<<endl;   void ShanChu(string str, student *&head) char delStr30; cout<<"歡迎使用刪除功能"<<endl

72、<<endl; cout<<"1->查詢刪除   2->全部刪除"<<endl; cin>>str; while(str0!='1' && str0!='2') cout<<"輸入錯誤,請重新輸入."<<endl; cin>>str; if(str0='1') cout<<"請輸入要刪除的關(guān)鍵字"<<en

73、dl; cin>>delStr; cout<<"1->刪除第一條找到的記錄      2->刪除所有找到的記錄"<<endl; cin>>str; while(str0!='1'&&str0!='2') cout<<"你輸入錯誤,請重新輸入."<<endl; cin>>str; cout<<"你真的要刪除嗎?  

74、   1->刪除 2->取消"<<endl; string s; cin>>s; if(str0='1') if(str0='1') Delete(head,delStr,1); else Delete(head,delStr,2); else cout<<"你已經(jīng)取消刪除了."<<endl; else cout<<"你真的要刪除全部數(shù)據(jù)嗎?這樣會使你的數(shù)據(jù)全部丟失哦."<<end

75、l; cout<<"1->全部刪除    2->取消刪除"<<endl; cin>>str; if(str0='1') DeleteAll(head); else cout<<"你已經(jīng)取消刪除了."<<endl; void PaiMing(string str, student* head) string s; cout<<"歡迎使用排名功能"&l

76、t;<endl<<endl; cout<<"排名選擇:    1->升序   2->降序"<<endl; cin>>s; cout<<"請輸入要按什么排名?"<<endl; cout<<"1->語文成績 2->數(shù)學(xué)成績 3->英語成績 " <<"4->總分 5->平均分

77、60;6->座號"<<endl; cin>>str; while(str0!='1' && str0!='2' && str0!='3' && str0!='4' && str0!='5' && str0!='6'  ) cout<<"你輸入錯誤,請重新輸入.&

78、quot;<<endl; cin>>str; cout<<"姓名:"<<setw(8)<<"座號:"<<setw(10) <<"語文分?jǐn)?shù):"<<setw(10) <<"數(shù)學(xué)分?jǐn)?shù):" <<setw(10)<<"英語分?jǐn)?shù):"<<setw(8)<<"總分?jǐn)?shù):" <<setw(8)<<"

79、平均分:"<<setw(6)<<"名次:"<<endl<<endl; if(s0='2') switch(str0) case '1': Sort(head,'1','1'); break; case '2': Sort(head,'2','1'); break; case '3': Sort(head,'3','1'); bre

80、ak; case '4': Sort(head,'4','1'); break; case '5': Sort(head,'5','1'); break; case '6': Sort(head,'6','1'); break; else switch(str0) case '1': Sort(head,'1','2'); break; case '2': Sort(head,'2','2'); break; case '3': Sort(head,'3','2'); break; case '4': Sort(head,'4','2'); break; case '5': Sort(head,'5

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論