編寫(xiě)的簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng)_第1頁(yè)
編寫(xiě)的簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng)_第2頁(yè)
編寫(xiě)的簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng)_第3頁(yè)
編寫(xiě)的簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng)_第4頁(yè)
編寫(xiě)的簡(jiǎn)單的學(xué)生成績(jī)管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩3頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、#include<iostream> #include<string> #include<iomanip> #include<fstream> using namespace std; class CData public: CData(); virtual int comparename(CData &) =0; virtual void show()=0; virtual CData(); ; class CNode public: CNode()pdata=0;pnext=0; CNode(CNode &n); void i

2、nputdata(CData *pd)pdata=pd; void shownode()pdata->show(); CData *getdata()return pdata; friend class CList; private: CData *pdata; CNode *pnext; ; CNode:CNode(CNode &n) pdata=n.pdata; pnext=n.pnext; class CList public: CList()phead=0; CList()deletelist(); void addnode(CNode *pnode); void del

3、etelist(); CNode *deletenode(CNode *pnode); CNode *lookup(CData &data); CNode *getlisthead()return phead; void showlist(); CNode *getnext(CNode *pnode); private: CNode * phead; ; void CList:addnode(CNode *pnode) if(phead=0) phead=pnode; pnode->pnext=0; return; else pnode->pnext=phead; phea

4、d=pnode; void CList:deletelist() CNode *p1,*p2; p1=phead; while(p1) delete p1->pdata; p2=p1; p1=p1->pnext; delete p2; CNode *CList:deletenode(CNode *pnode) CNode *p1,*p2; p1=phead; while(p1!=pnode&&p1->pnext!=0) p2=p1; p1=p1->pnext; if(p1=phead) phead=phead->pnext; return pnod

5、e; p2->pnext=p1->pnext; return pnode; CNode *CList:lookup(CData &data) CNode *p1=phead; while(p1) if(p1->pdata->comparename(data)=0) return p1; p1=p1->pnext; return 0; void CList:showlist() if(phead=0) cout<<"對(duì)不起,沒(méi)有任何記錄.n" else CNode *p=phead; while(p) p->pdata-

6、>show(); p=p->pnext; CNode *CList:getnext(CNode *pnode) CNode *p=pnode; p=p->pnext; return p; class Student:public CData private: char s_class17; char s_num17; char s_name17; double ele_technique; double c_program; double mul_technique; double col_english; double sen_math; double col_gym; d

7、ouble marx_economy; double average; public: Student(); virtual int comparename(CData &); void show(); void set(char *c,char*n,char *nam,double e,double cp, double m,double ce,double sm,double cg,double mar,double aver); ; Student:Student() strcpy(s_class,"0"); strcpy(s_num,"0"

8、;); strcpy(s_name,"0"); ele_technique=0; c_program=0; mul_technique=0; col_english=0; sen_math=0; col_gym=0; marx_economy=0; int Student:comparename(CData &data) Student &temp=(Student &)data; return strcmp(s_name,temp.s_name); void Student:show() cout<<setw(7)<<s_c

9、lass<<setw(12)<<s_num<<setw(12)<<s_name; cout<<setw(6)<<ele_technique<<setw(6)<<c_program<<setw(6)<<mul_technique; cout<<setw(6)<<col_english<<setw(6)<<sen_math<<setw(6)<<col_gym; cout<<setw(6)<&

10、lt;marx_economy<<" "<<setw(3)<<average<<endl; void Student:set(char *c,char*n,char *nam,double e,double cp,double m,double ce,double sm,double cg,double mar,double aver) strcpy(s_class,c); strcpy(s_num,n); strcpy(s_name,nam); ele_technique=e; c_program=cp; mul_techn

11、ique=m; col_english=ce; sen_math=sm; col_gym=cg; marx_economy=mar; average=aver; void print() cout<<setw(7)<<"class"<<setw(12)<<"number"<<setw(12)<<"name" cout<<setw(6)<<"ele"<<setw(6)<<"C+"

12、<<setw(6)<<"media" cout<<setw(6)<<"eng"<<setw(6)<<"math"<<setw(6)<<"gym" cout<<setw(6)<<"marx"<<setw(6)<<"aver"<<endl; void display(CList &stulist) print(); s

13、tulist.showlist(); cout<<endl; cout<<"按任意鍵返回主菜單" getchar();getchar(); void add(CList &stulist) CNode *p; Student *s; char c17,n17,nam17; double e,cp,m,ce,sm,cg,mar;float aver; cout<<"請(qǐng)輸入姓名(輸入0結(jié)束):" cin.ignore(); cin.getline(nam,17); while(strcmp(nam,"0&

14、quot;) cout<<"輸入學(xué)號(hào):"cin.getline(n,17); cout<<"輸入班級(jí):"cin.getline(c,17); cout<<"輸入計(jì)算機(jī)成績(jī):"cin>>e; cout<<"輸入大學(xué)英語(yǔ)成績(jī):"cin>>ce; cout<<"輸入高等數(shù)學(xué)成績(jī):"cin>>sm; aver=(e+cp+m+ce+sm)*0.8/5+cg*0.15+mar*0.05); s=new Stud

15、ent; s->set(c,n,nam,e,cp,m,ce,sm,cg,mar,aver); p=new CNode; p->inputdata(s); stulist.addnode(p); cout<<"記錄添加成功."<<endl; cout<<"請(qǐng)輸入姓名(輸入0結(jié)束):" cin.ignore(); cin.getline(nam,17); void lookup(CList &stulist) CNode *plook; char name17; cout<<"請(qǐng)輸

16、入你要查找的姓名(輸入0結(jié)束):" cin.ignore(); cin.getline(name,17); while(strcmp(name,"0") Student s; s.set("0","0",name,0,0,0,0,0,0,0,0); plook=stulist.lookup(s); if(plook) print(); plook->shownode(); else cout<<"對(duì)不起,在學(xué)生記錄中查找不到"<<name<<"的記錄.&

17、quot;<<endl; cout<<"請(qǐng)輸入你要查找的姓名(輸入0結(jié)束):" cin.getline(name,17); void deletes(CList &stulist) CNode *plook; char name17; cout<<"請(qǐng)輸入要?jiǎng)h除的記錄的學(xué)生姓名(輸入0結(jié)束):" cin.ignore(); cin.getline(name,17); while(strcmp(name,"0") Student s; s.set("0","0&q

18、uot;,name,0,0,0,0,0,0,0,0); plook=stulist.lookup(s); if(plook) print(); plook->shownode(); stulist.deletenode(plook); cout<<name<<"的記錄已經(jīng)刪除.n" else cout<<"對(duì)不起,在學(xué)生記錄中查找不到"<<name<<"的記錄.n"<<endl; cout<<"請(qǐng)輸入要?jiǎng)h除的記錄的學(xué)生姓名(輸入0結(jié)束)

19、:" cin.getline(name,17); void storefile(CList &stulist) ofstream outfile("student.dat",ios:binary); if(!outfile) cout<<"數(shù)據(jù)文件打開(kāi)錯(cuò)誤,數(shù)據(jù)存入文件失??!"<<endl; return; CNode *p; Student *s; p=stulist.getlisthead(); while(p) s=(Student *)p->getdata(); outfile.write(char

20、 *)s,sizeof(Student); p=stulist.getnext(p); outfile.close(); void loadfile(CList &stulist) ifstream infile("student.dat",ios:binary); if(!infile) cout<<"沒(méi)有數(shù)據(jù)文件!"<<endl; return; CNode *p; Student *s; while(! infile.eof() s=new Student; infile.read(char *)s,sizeof(Student); p=new CNode; p->inputdata(s); stulist.addnode(p); stulist.deletenode(p); infile.close(); void operate(CList &stulist) int choice; do system("cls")

溫馨提示

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

評(píng)論

0/150

提交評(píng)論