第一篇:簡單學(xué)生信息管理系統(tǒng)C++范文
#include
#include
using namespace std;
int i=0;
void layout()
{
cout<<“歡迎使用學(xué)生信息系統(tǒng)”< cout<<“請選擇功能序號:”< cout<<“0.輸入學(xué)生信息”< cout<<“1.計算平均分并排序”< cout<<“2.統(tǒng)計學(xué)科平均分”< cout<<“3.統(tǒng)計班級平均分”< cout<<“4.按學(xué)號修改學(xué)生信息”< cout<<“5.根據(jù)學(xué)號查詢學(xué)生信息”< cout<<“---------萬惡的分割線----------”< } class student { private: int num; string name; double score1,score2; public: double c; int banji; string sex; student(){} void set_student(int bj,int n,string nam,string s,double les1,double les2){ banji=bj; num=n; name=nam; sex=s; score1=les1; score2=les2; } int get_score1() { return score1; } int get_score2() { return score2; } int get_num() { return num; } void show() { c=(score1+score2)/2; cout< } }stu[20]; void show_1() { cout<<“班級:t學(xué)號t姓名t性別t學(xué)科一t學(xué)科二t平均分”< } //學(xué)生信息輸入// void INPUT() { int j=0; int x; do{int banji;int num;string name;string sex;double score1,score2; cout<<“請輸入學(xué)生信息:”< cout<<“班級:t”<<“學(xué)號:t”<<“姓名:t”<<“性別:t”<<“學(xué)科一:t”<<“學(xué)科二:t”< cin>>banji>>num>>name>>sex>>score1>>score2; stu[i].set_student(banji,num,name,sex,score1,score2); i++; cout<<“是否繼續(xù)輸入學(xué)生信息?是:請輸入0/否:請輸入1”< cin>>x; }while(x==0); show_1(); for(j=0;j { stu[j].show(); } } //計算平均分并排序// void Paixu() {student stu1; for(p=0;p<=i-1;p++) { k=p; for(j=p+1;j if(stu[j].c {k=j; stu1=stu[k];stu[k]=stu[p];stu[p]=stu1; } } show_1(); for(j=0;j { stu[j].show(); } } //統(tǒng)計學(xué)科平均分// void xueke() { double q1; double sum1; int p1; for(p1=0;p1<=i;p1++) { sum1=sum1+stu[p1].get_score1(); } q1=sum1/i; cout<<“學(xué)科一平均成績:”< double q2; double sum2; int p2; for(p2=0;p2<=i;p2++) { sum2=sum2+stu[p2].get_score2(); } q2=sum2/i; cout<<“學(xué)科二平均成績:”< } //統(tǒng)計班級平均分// void banji() double q1,q2; double sum1,sum2; int p,m; m=0; sum1=0;sum2=0; for(p=0;p<=i;p++) { a[p]=stu[p].banji; } for(m=0;m<=i;m++) {int t=1; sum1=stu[m].get_score1(); sum2=stu[m].get_score2(); for(p=m+1;p<=i;p++) { if((a[m]==a[p])&&a[p]!=0) { sum1=sum1+stu[p].get_score1(); sum2=sum2+stu[p].get_score2(); a[p]=0; t++; } } if(a[m]!=0){ q1=sum1/t; q2=sum2/t; cout<<“電信”< cout<<“學(xué)科二平均成績:”< } } } //按學(xué)號查詢學(xué)生信息// void chaxun() {int x; cout<<“請輸入學(xué)號:”; cin>>x; int p; for(p=0;p<=i;p++) { if(x==stu[p].get_num()) { show_1(); stu[p].show(); } } } //按學(xué)號修改學(xué)生信息// void xiugai() { int j; int x; cout<<“請輸入需修改學(xué)號:”; cin>>x; int p; for(p=0;p<=i;p++) { if(x==stu[p].get_num()) { int banji;int num;string name;string sex;double score1,score2; cout<<“請輸入學(xué)生信息:”< cout<<“班級:t”<<“學(xué)號:t”<<“姓名:t”<<“性別:t”<<“學(xué)科一:t”<<“學(xué)科二:t”< cin>>banji>>num>>name>>sex>>score1>>score2; stu[p].set_student(banji,num,name,sex,score1,score2); show_1(); for(j=0;j { stu[j].show(); } } } } int main() {layout(); int flag; int n; for(n=0;n<=100;n++) { cin>>flag; switch(flag){ case 0: cout<<“輸入范例:”; cout<<“班級:t”<<“學(xué)號:t”<<“姓名:t”<<“性別:t”<<“學(xué)科一:t”<<“學(xué)科二:t”< cout<<“1 1109 朱偉 男 100 98”< cout<<“---------萬惡的分割線----------”< INPUT(); break; case 1: Paixu(); break; case 2: xueke(); break; case 3: banji(); break; case 4: chaxun(); break; case 5: xiugai(); break; case 6: n=100; }cout<<“再見!謝謝使用本系統(tǒng)!”;break;default:cout<<“請重新輸入功能序號:”;break;}} C++程序設(shè)計實踐教學(xué)環(huán)節(jié)任務(wù)書 一、題目:學(xué)生信息管理系統(tǒng) 二、目的與要求 1.目的: (1)掌握面向?qū)ο蟪绦蛟O(shè)計的基本思路和方法; (2)了解系統(tǒng)開發(fā)的需求分析、類層次設(shè)計、模塊分解、編碼測試、模塊 組裝與整體調(diào)試的全過程; (3)進(jìn)一步熟悉C++中類的概念、類的封裝、繼承的實現(xiàn)方式;(4)學(xué)會分析簡單的實際問題,并能利用所學(xué)的知識建立系統(tǒng)的邏輯結(jié)構(gòu),學(xué)會簡單的調(diào)試技巧和方法。逐步熟悉面向?qū)ο蟪绦蛟O(shè)計的方法,養(yǎng)成良好的編程習(xí)慣。 2.要求基本要求: (1)要求利用C++面向?qū)ο蟮木幊趟枷雭硗瓿上到y(tǒng)的設(shè)計;(2)進(jìn)行簡單界面設(shè)計,能夠?qū)崿F(xiàn)友好的交互;(3)具有清晰的程序流程圖和數(shù)據(jù)結(jié)構(gòu)的詳細(xì)定義;(4)熟練掌握C++對文件的各種操作。 三、信息描述 有關(guān)該系統(tǒng)基本信息的描述(如:學(xué)號、姓名、系別、班級和各科成績等)。 四、功能描述 1.添加、刪除 系統(tǒng)將提示用戶輸入新添加學(xué)生的信息;由用戶輸入要刪除的學(xué)生的學(xué)號,然后調(diào)用刪除函數(shù),刪除該名學(xué)生的資料。2.查找 首先由用戶輸入要查找的學(xué)生的學(xué)號,系統(tǒng)用查找函數(shù)查找,然后系統(tǒng)就調(diào)用輸出函數(shù)。 3.修改 首先由用戶輸入要修改的學(xué)生的學(xué)號,然后系統(tǒng)用修改函數(shù)查找,顯示該名學(xué)生的資料,然后系統(tǒng)提示用戶輸入需要修改的項目和新的資料。4.界面要求 開始登錄管理界面、主要提示菜單界面(提示用戶執(zhí)行何種操作)等。 五、解決方案 1.分析程序的功能要求,劃分程序功能模塊。2.畫出系統(tǒng)流程圖。 3.代碼的編寫、程序的功能調(diào)試。4.完成系統(tǒng)總結(jié)報告以及使用說明書 六、進(jìn)度安排 此次課程設(shè)計時間為一周或兩周,分四個階段完成: 1.分析設(shè)計階段。指導(dǎo)教師應(yīng)積極引導(dǎo)學(xué)生自主學(xué)習(xí)和鉆研問題,明確 設(shè)計要求,找出實現(xiàn)方法,按照需求分析、總體設(shè)計、詳細(xì)設(shè)計這幾個步驟進(jìn)行。 2.編碼調(diào)試階段:根據(jù)設(shè)計分析方案編寫代碼,然后調(diào)試該代碼,實現(xiàn) 課題要求的功能。 3.總結(jié)報告階段:總結(jié)設(shè)計工作,寫出課程設(shè)計說明書,要求學(xué)生寫出需 求分析、總體設(shè)計、詳細(xì)設(shè)計、編碼、測試的步驟和內(nèi)容。4.考核階段。 七、撰寫課程設(shè)計報告或課程設(shè)計總結(jié) 總結(jié)報告包括需求分析、總體設(shè)計、詳細(xì)設(shè)計、編碼(詳細(xì)寫出編程步驟)、測試的步驟和內(nèi)容、課程設(shè)計總結(jié)、參考資料等,不符合以上要求者,則本次設(shè)計以不及格記。 八、參考資料 《C++語言程序設(shè)計教程》 網(wǎng)上相關(guān)資料(....略) 1.C++課程設(shè)計題目:《學(xué)校人員信息管理系統(tǒng)》 用c++設(shè)計一個大學(xué)教師和學(xué)生管理程序,教師包括編號(a),姓名(c),職稱(d)和教研室數(shù)據(jù)(b)的數(shù)據(jù)輸入輸出;大學(xué)生包括編號(m),姓名(s),性別(t),班號(n),英語(e),高等數(shù)學(xué)(f)和數(shù)據(jù)結(jié)構(gòu)(g)三門課程成績輸入輸出和計算機平均分(ave);研究生包括編號,姓名,性別,班號,指導(dǎo)教師和研究方法數(shù)據(jù)輸入輸出;博士后數(shù)據(jù)的輸入輸出;博士后既是教師也是研究生.(用派生,繼承的方法可以做)2.功能如下圖所示: 學(xué)生成績管理系統(tǒng)主函數(shù)主菜單錄入學(xué)生信息保存信息到文件瀏覽學(xué)生信息按姓名或?qū)W號查詢信息刪除信息退出系統(tǒng) 3.部分代碼 #include int compareStr(char*str1,char*str2);//名字作為關(guān)鍵字,這個函數(shù)就用來比較 void addList(chainList *list);//同名的話,覆蓋,或者改為新名字加入 void deleteNode(chainList *node);//根據(jù)名字刪除 void editList(chainList *list,char *name);//要編輯的人名和新的資料 chainList *searchList(chainList *list,char*name);//只提供名字查詢(其他以后加入)//返回前一個節(jié)點的指針 void orderList(chainList *list);//按名字排序 void orderListByAge(chainList *list);//按年齡降序排列 void orderListBySex(chainList *list);//按照性別排列,女士優(yōu)先 void printStaticInfo(chainList*list);void printList(chainList *list);int main(){cout<<“tYou are welcome to the management system!”< cout<<“File's name:”< cin>>fileName; file.open(fileName);if(!file)//為何輸入不存在地文件后,機子變得很慢,而且沒有結(jié)果出來? {cout<<“File not found!System exit.”< return 1; } // cout<<“test”< fileRead(head,file);//讀入文件到鏈表 file.close();} printStaticInfo(head);char ctn; do {cout<<“main menu:”< addList(head); break;case '2': cout<<“Please input the person's name to be deleted:”< char nm[20]; cin>>nm; chainList *pdel; pdel=searchList(head,nm); char sure;//Make sure whether you want to delete the data sure='n'; if(!pdel->next) { cout<<“The person you input cann't be found”< } else{ cout<<“The persons infor follows:”< pdel->next->pl->print(); cout<<“Are you sure to delete it?Press y or n”< cin>>sure; if(sure=='y') { deleteNode(pdel); cout< } } break;case '3': cout<<“Please input the person's name:”< pp=searchList(head,nm1); if(pp->next) { cout<<“The person's infor follows:”< pp->next->pl->print(); cout<<“Now ,please edit the infors.”< editList(head,nm1); } else cout<<“The person can't be found!”< break; case '4': cout<<“Please input the person's name:”< char name[30]; cin>>name; chainList *p; p=searchList(head,name); if(p->next) { p->next->pl->print(); } else cout<<“The person can't be found!”< break; case '5': cout<<“You want to order the list by:”< cout<<“1.name 2.age 3.sex(lady first)”< char ch; cin>>ch; switch(ch) { case '1': cout<<“You choose to order the list by name.The result are as follows:”< orderList(head); printStaticInfo(head); break; case '2': cout<<“You choose to order the list by age.The result are as follows:”< orderListByAge(head); printStaticInfo(head); break; case '3': cout<<“You choose to order the list by sex.The result are as follows:”< orderListBySex(head); printStaticInfo(head); break; default: cout<<“Wrong choice!”< } break; case '6': printStaticInfo(head); break; default: cout<<“Wrong choice!”< } }while(ctn!='0');cout<<“Do you want to save the file?No,press n.Else,any other key.”< cout<<“Please input the file's name:”< cin>>fileName; ofstream fin; fin.open(fileName);//如果文件已經(jīng)存在,詢問是否覆蓋。如何知道是否存在 if(!fin) { cout<<“Can't open output file.n”; return 1; } fileWrite(head,fin); fin.close(); cout<<“File has been successfully saved!”< void fileRead(chainList *list,ifstream &ff){ chainList*p=list;int tp; } char nm[20];int ag;char sx;int slr;int grd; int e;int m;int g;int average;char schl[20];char sb[20];int teaYear;int aa=1;persons*psn;//插入人員指針 ff>>tp;while(tp){ ff>>ag; ff>>nm; ff>>sx; switch(tp){ case 1: ff>>grd;ff>>schl; psn=new student(ag,nm,sx,grd,schl,e,m,g,average); break;case 2: ff>>sb; ff>>teaYear; psn=new teacher(ag,nm,sx,sb,teaYear); break;case 3: ff>>slr; psn=new empoyee(ag,nm,sx,slr); break;} } chainList*s=new chainList(tp,psn);p->next=s;p=s;ff>>tp;void fileWrite(chainList *list,ofstream &ff){ chainList*p=list->next;while(p){ ff< typeOfPn<<“ ”< pl->age<<“ ”< pl->name<<“ ”< pl->sex<<“ ”; switch(p->typeOfPn) { case 1: ff<<((student*)p->pl)->grade<<“ ”<<((student*)p->pl)->school< break; case 2: ff<<((teacher*)p->pl)->subject<<“ ”<<((teacher*)p->pl)->yearsOfT< break; case 3: ff<<((empoyee*)p->pl)->salary< break; } p=p->next;} int aa=0;ff< int i=0;while((p1[i]==p2[i])&&p1[i]&&p2[i]) i++;if(p1[i]==p2[i]){ return 0;} else { if(p1[i]>p2[i]) return 1; else return-1;} } void addList(chainList *list)//添加節(jié)點 { char tp;int type;do{ cout<<“The person whose info you want to input is:”< 2.a teacher 3.a common employee”< char nm[20];int ag;char sx;int slr;int grd;char schl[20]; int e;int m; int g;int average;char sb[20];int teaYear;int aa=1;persons*psn;//插入人員指針 switch(tp){ case '0':aa=0; type=0; break;case '1': type=1; cout<<“name:”< cin>>nm; cout<<“age:”< cin>>ag; cout<<“male or female?m or f?”< cin>>sx; cout<<“The student's grade”< cin>>grd; cout<<“From which school:”< cin>>schl; cout<<“the score of english:”< cin>>e; cout<<“the score of math:”< cin>>m; cout<<“the score of sjjg:”< cin>>g; cout<<“average:”< psn=new student(ag,nm,sx,grd,schl,e,m,g,average); break; case '2':type=2; cout<<“name:”< cin>>nm; cout<<“age:”< cin>>ag; cout<<“male or female?m or f?”< cin>>sx; cout<<“subject field:”< cin>>sb; cout<<“Years as a teacher:”< cin>>teaYear; psn=new teacher(ag,nm,sx,sb,teaYear); break; case '3':type=3; cout<<“name:”< cin>>nm; cout<<“age:”< cin>>ag; cout<<“male or female?m or f?”< cin>>sx; cout<<“The employee's salary:”< cin>>slr; psn=new empoyee(ag,nm,sx,slr); break; default:type=6; aa=0; cout<<“Wrong choice!”< } chainList*p=list;//新節(jié)點在p所指的節(jié)點之前插入,if(aa) { int com; if(p->next) { com=compareStr(nm,p->next->pl->name); cout< } while(p->next&&com>0)//比p節(jié)點小或者p為空退出 { p=p->next; if(p->next) com=compareStr(nm,p->next->pl->name); } chainList *s=new chainList(type,psn); s->next=p->next; p->next=s; } }while(type); } void deleteNode(chainList *node){ chainList*ptemp=node->next; node->next=ptemp->next; delete ptemp;} void editList(chainList *list,char *name)//刪除,添加就是編輯。缺點:不想刪除的也被刪除了。{ chainList *pde;pde=searchList(list,name); char tp;int type;do{ cout<<“The person whose info you want to input is:”< cout<<“1.a student 2.a teacher 3.a common employee”< cout<<“0.Return to main menu.”< cin>>tp;//為什么一輸入字符就死循環(huán)?? char nm[20]; int ag; char sx; int slr; int grd; char schl[20]; int e; int m; int g; int average; char sb[20]; int teaYear; int aa=1; persons*psn;//插入人員指針 if(tp==1||tp==2||tp==3) deleteNode(pde);switch(tp){ case '0':aa=0;type=0;break;case '1': type=1;cout<<“name:”< cout<<“age:”< cin>>ag; cout<<“male or female?m or f?”< cin>>sx; cout<<“The employee's salary:”< cin>>slr; psn=new empoyee(ag,nm,sx,slr); break; default:type=6; aa=0; cout<<“Wrong choice!”< } chainList*p=list;//新節(jié)點在p所指的節(jié)點之前插入,if(aa) { int com; if(p->next) { com=compareStr(nm,p->next->pl->name); cout< } while(p->next&&com>0)//比p節(jié)點小或者p為空退出 { p=p->next; if(p->next) com=compareStr(nm,p->next->pl->name); } chainList *s=new chainList(type,psn); s->next=p->next; p->next=s; } }while(type); } chainList *searchList(chainList *list,char*name)//查找函數(shù) { chainList *p=list;int com;if(p->next) com=compareStr(name,p->next->pl->name); while(p->next&&com)//com為0值(即名字相同)或者p->next為空退出 { p=p->next;if(p->next)com=compareStr(name,p->next->pl->name);} return p;} void orderList(chainList *list){ chainList *p,*q;p=list;q=p->next;while(q->next&&p){ while((p->next!=q->next)&&p->next)//如果相等,則什么也不做 { int i=compareStr(q->next->pl->name,p->next->pl->name); i=-i; if(i>0)//字母順序小的插在前面 { chainList*s; s=q->next; q->next=s->next; s->next=p->next; p->next=s; p=s; break; } if(i==0)//字母順序相同的插到后面 { chainList*ss; ss=q->next; q->next=ss->next; p=p->next;//讓p永遠(yuǎn)指向插入位置前一個位置。 ss->next=p->next; p->next=ss; p=ss; break; } p=p->next; } p=list;//讓p重新指向頭節(jié)點。 if(q->next) q=q->next;//q前進(jìn)一步。 } } void orderListByAge(chainList *list){ chainList*p,*q;p=list;q=p->next;while(q->next&&p){ while(p->next!=q->next)//如果相等,則什么也不做 { int i=q->next->pl->age-p->next->pl->age; if(i>0)//年齡大的插到用于比較的節(jié)點前面 { chainList*s; s=q->next; q->next=s->next; s->next=p->next; p->next=s; p=s; break; } if(i==0)//年齡相同的插到后面 { chainList*ss; ss=q->next; q->next=ss->next; p=p->next;//讓p永遠(yuǎn)指向插入位置前一個位置。 ss->next=p->next; p->next=ss; p=ss; break; } p=p->next; } p=list;//讓p重新指向頭節(jié)點。 if(q->next) q=q->next;//q前進(jìn)一步。 } } void orderListBySex(chainList *list)//按性別排序,插入排序 { chainList*p,*q;p=q=list; while(q->next){ if(q->next->pl->sex=='f') { chainList*s; s=q->next; q->next=s->next;//刪除,然后插到前面 s->next=p->next; p->next=s; p=s; } q=q->next;} } void printStaticInfo(chainList*list){ int count,countS,countT,countE,countMale,countFemale;count=countS=countT=countE=countMale=countFemale=0;chainList*p=list->next;while(p){ p->pl->print(); count++; if(p->pl->sex=='m') countMale++; else countFemale++; switch(p->typeOfPn) { case 1: countS++; break; } case 2: countT++; break;case 3: countE++; break;} p=p->next; } cout<<“********************************************”< 部分截圖 1.信息的輸入 2.瀏覽學(xué)生信息 開始N開始YNY輸出所有信息返回主菜單錄入信息保存信息返回主菜單打開文件文件中有無信息結(jié)束3.按姓名或?qū)W號查詢信息 4.刪除信息 開始NY輸入姓名或?qū)W號開始NY輸入姓名或?qū)W號N 打開文件打開文件Y輸出信息(name==sign)||(number==sign))Y刪除信息(name==sign)||(number==sign))N返回主菜單返回主菜單 心得體會: 通過本次課程設(shè)計懂得了,學(xué)習(xí)計算機語言知識,要不斷實踐,不斷學(xué)習(xí)新的內(nèi)容,特別是課堂中沒有涉及的內(nèi)容要自主的去學(xué)習(xí)并學(xué)會運用。在今后的學(xué)習(xí)中我要加強自主學(xué)習(xí)的能力,加強動手能力。通過一星期的C++語言程序設(shè)計課程設(shè)計,我們從中受益匪淺,并且對C++語言程序設(shè)計這一門課程有了更深一步的認(rèn)識。在實習(xí)中,我們可以把這學(xué)期所學(xué)的理論知識和實踐聯(lián)系起來,在所要開發(fā)的項目中漸漸成長。雖然我們對這些C++語言知識運用得還不是很熟練,但是相信我們也在滴水穿石地成長起來。發(fā)現(xiàn)問題,提出問題,解決問題使我們從不足之處出發(fā),尋找新的方向。在課程設(shè)計中,我設(shè)計了一個學(xué)生信息管理系統(tǒng),它基本足了界面友好,易于操作的要求,因此更利于用戶操作方便,運行簡易,從而達(dá)到對人員管理更加有效系統(tǒng)的管理,并且速度更快內(nèi)容更直接地達(dá)到用戶所想要的效果。在該軟件中我們實現(xiàn)了對學(xué)生信息的輸入和存取、讀取,對學(xué)生相關(guān)信息的刪除等,并且可以按學(xué)號查詢學(xué)生的相關(guān)信息等的功能。但軟件中仍然存在一些不足,例如在輸入有關(guān)學(xué)生的數(shù)據(jù)時名字沒有限定,插入新的學(xué)生信息的程序還有待完善,菜單不美觀等。我一邊設(shè)計一邊探索,發(fā)現(xiàn)理論和實踐要充分地結(jié)合,是需要扎實的基本功的,這就表明學(xué)好基礎(chǔ)知識是理論付諸實踐的前提。在實習(xí)中我們學(xué)到了很多,希望在以后我們能充分利用這樣的機會充實自己,并希望這樣的機會能被更好更多地提供。 教職工信息管理系統(tǒng)源碼 #include #define maxsize 100 fstream iofile;//文件指針 class Time //時間類 { public: int year; int month; int day;}; class Telem //個人信息 { public: char name[20]; char sex[10]; Time birthtime;//組合Time類 char num[20]; char wage[20]; Time worktime; int year; char department[20]; friend istream& operator>>(istream& input,Telem& T); friend ostream& operator<<(ostream& output,Telem& T); friend int operator-(Time & t1,Time & t2);}; class People:virtual public Telem //雇員類 { public: People(); virtual void AddF()=0;//添加 virtual void Addall()=0; virtual void Add()=0; virtual void Display();//輸出數(shù)組的內(nèi)容 virtual void Displaypart(char p[]); virtual void Findname(char n[]); virtual void Findyear(int); virtual void Del(char n[])=0; virtual void Del(int);protected: Telem data[maxsize]; Time now; int length;}; class Teacher:virtual public People //派生虛基類 { public: virtual void AddF(); virtual void Addall(); virtual void Add(); virtual void Display(); virtual void Del(int i); virtual void Del(char n[]);}; class worker:virtual public People //派生虛基類 { public: virtual void AddF(); virtual void Addall(); virtual void Add(); virtual void Display(); virtual void Del(int i); virtual void Del(char n[]);}; People::People()//系統(tǒng)自動生成的構(gòu)造函數(shù) { length=0; now.year=2010; now.month=7; now.day=6;} void People::Display()//引用 { int i; for(i=0;i cout< void People::Displaypart(char p[])//引用數(shù)組 { int i,c; for(i=0;i if(strcmp(data[i].wage,p)==0) { cout<<“輸出選擇姓名1 性別2 編號3 工資4 出生日期5 工作時間6 年齡7 系別8 退出選擇9”< while(cin>>c) { switch(c) { case 1: cout<<“姓名:”< case 2: cout<<“性別:”< case 3: cout<<“編號:”< case 4: cout<<“工資:”< case 5: cout<<“出生日期:”< case 6: cout<<“工作時間:”< case 7: cout<<“年齡:”< case 8: cout<<“系別:”< case 9: goto loop; default:cout<<“操作錯誤......”< } } loop:; } } void People::Findname(char n[])//引用 { int i; for(i=0;i if(strcmp(data[i].name,n)==0)//對象引用 cout< void People::Findyear(int y){ int i; for(i=0;i if(data[i].year==y) cout< void People::Del(int i){ int j; if(i<1||i>length) cout<<“不存在第”< for(j=i;j data[j-1]=data[j]; length--;} void worker::AddF(){ int flag=0; iofile.open(“worker_information.txt”,ios::in|ios::binary);//文件的打開與關(guān)閉 while(iofile.seekg(ios::cur)) { iofile.seekg(length*sizeof(data[length]),ios::beg); iofile.read((char*)&data[length],sizeof(data[length]));//文件的隨機訪問 length++; if(length==maxsize) { flag=1; goto loop; } } People::Del(length); cout<<“添加人員信息成功......”< loop: if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void worker::Addall(){ char ans; int flag=0; iofile.open(“worker_information.txt”,ios::out|ios::binary); do { cin>>data[length]; data[length].year=now-data[length].birthtime; iofile.write((char*)&data[length],sizeof(data[length])); cout<<“添加人員信息成功......”< length++; if(length==maxsize) { flag=1; goto loop; } cout<<“contine(Y|N)?”; cin>>ans; }while('y'==ans||'Y'==ans);loop: if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void worker::Add(){ int flag=0; iofile.open(“worker_information.txt”,ios::app|ios::out|ios::binary); if(length==maxsize) { flag=1; goto loop; } cin>>data[length]; data[length].year=now-data[length].birthtime; iofile.write((char*)&data[length],sizeof(data[length])); cout<<“添加人員信息成功......”< length++; loop: if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void worker::Display(){ cout<<“ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆工人信息 ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆”< if(0==length) cout<<“無......”< int i; for(i=0;i cout< int i,j,k; for(i=0;i if(strcmp(data[i].name,n)==0){ k=i+1;break;} if(k<1) cout<<“不存在姓名”< for(j=k;j data[j-1]=data[j]; length--; cout<<“刪除人員信息成功......”< void worker::Del(int i){ int j; if(i<1||i>length) cout<<“不存在第”< for(j=i;j data[j-1]=data[j]; length--; cout<<“刪除成功......”< } void Teacher::AddF(){ int flag=0; iofile.open(“Teacher_information.txt”,ios::in|ios::binary); while(iofile.seekg(sizeof(data[length]),ios::cur)) { if(iofile.seekg(length*sizeof(data[length]),ios::beg)) iofile.read((char*)&data[length],sizeof(data[length])); else break; length++; if(length==maxsize) { flag=1; goto loop; } } People::Del(length); cout<<“添加人員信息成功......”< if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void Teacher::Addall(){ char ans; int flag=0; iofile.open(“Teacher_information.txt”,ios::in|ios::out|ios::binary); do { cin>>data[length]; data[length].year=now-data[length].birthtime; iofile.write((char*)&data[length],sizeof(data[length])); cout<<“添加人員信息成功......”< length++; if(length==maxsize) { flag=1; goto loop; } cout<<“contine(Y|N)?”; cin>>ans; }while('y'==ans||'Y'==ans);loop: if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void Teacher::Add(){ int flag=0; iofile.open(“Teacher_information.txt”,ios::app|ios::out|ios::binary); if(length==maxsize) { flag=1; goto loop; } cin>>data[length]; data[length].year=now-data[length].birthtime; iofile.write((char*)&data[length],sizeof(data[length])); cout<<“添加人員信息成功......”< length++;loop: if(1==flag) cout<<“人員信息儲存空間已滿......”< iofile.close();} void Teacher::Display(){ cout<<“ ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆教師信息 ★ ☆ ★ ☆ ★ ☆ ★ ☆ ★ ☆”< if(0==length) cout<<“無......”< int i; for(i=0;i cout<第二篇:C++課程設(shè)計學(xué)生信息管理系統(tǒng)
第三篇:c++學(xué)校人員信息管理系統(tǒng)
第四篇:C++課程設(shè)計 教職工信息管理系統(tǒng)源代碼