1、学生管理系统源代码范本模板#includeiostream#includeincludestring。h#include#define INIT_SIZE 10 #define INCRE_SIZE 10 define SUBJECT_NUM 3#define LEN 3void show_Start();void show_Table();void addRecord();void Info_delete();void deleteRecord();void delete_Num(int);void delete_Name(char tarName);void Info_modify();v
2、oid modifyRecord();void modify_Num(int);void modify_Name(char);void Info_query();void queryRecord();void query_Num(int);void query_Name(char);void display();void quit();void menu_CMD();char *subjectSUBJECT_NUM = struct STUDENT int num; char name20; char sex; float scoreSUBJECT_NUM; /struct STUDENT s
3、tuLEN + 1;/STUDENT record = (STUDENT)malloc(sizeof(STUDENT)*INIT_SIZE);int static stuNum = 0; /STUDENT record = (STUDENT)malloc(sizeof(STUDENT)INIT_SIZE);int main() /record = (STUDENT*)malloc(sizeof(STUDENT)INIT_SIZE); /STUDENT record = (STUDENT)malloc(sizeof(STUDENT)INIT_SIZE);/ record1.num = 1001;
4、 strcpy(record1。name,Jason); record1.sex = M; record1.score0 = 85.0; record1。score1 = 90.0; record1.score2 = 95。0;record2。num = 1002; strcpy(record2。name,Jerry”); record2.sex = M; record2。score0 = 85。0; record2.score1 = 90。0; record2.score2 = 95。0;record3。num = 1003; strcpy(record3.name,Jessie); rec
5、ord3.sex = F; record3.score0 = 85.0; record3.score1 = 90.0; record3。score2 = 95.0;*/* Info_modify(); int key; cout cinkey; if(key = 1) int targetNum; cout cintargetNum; modify_Num(targetNum); coutendl; display(); if(key = 2) char targetName20; cout cintargetName; modify_Name(targetName); coutendl; d
6、isplay(); if(key = 3) exit(0); */ show_Start();menu_CMD();return 0; void show_Start() /coutendl; cout * ”endl; cout endl; cout ”endl; cout ”endl; cout” endl; cout Made by Jason endl; cout * endl;/。 void show_Table() cout” t” ”t” couttsubject0”tsubject1”t”subject2; coutendl; void menu_CMD() int key;
7、while(1) cout”1。 endl; cout”2. endl; cout3。 endl; cout”4. endl; cout5。 endl; cout6. endl; cout” cinkey; while(1) if((key 1)|(key 6)) int key; cout ”endl; coutkey; else break; switch(key) case 1: addRecord(); break; case 2: deleteRecord(); break; case 3: modifyRecord(); break; case 4: queryRecord();
8、break; case 5: display(); break; case 6: quit(); break; /void addRecord()if(stuNum = 0) cout endl; stuNum+; else cout INIT_SIZE) cout ”endl; record = (STUDENT)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT)); cout” !endl; cout” endl; cout” (Y/N) : ; char choi; cinchoi; if((choi = Y)|(choi =
9、y) cout” : ; cinrecordstuNum。num; coutrecordstuNum。name; coutrecordstuNum。sex; int i; for(i = 0;i SUBJECT_NUM;i+) cout” subjectirecordstuNum。scorei; if((choi = N)|(choi = n)) cout endl; coutendl; cout stuNum !”endl; coutendl;/ /deleteRecord void Info_delete() cout” : endl; cout”1. ”endl; cout”2。 end
10、l; cout3。 ”endl;/ void deleteRecord() int key; coutendl; Info_delete(); coutkey; if(key = 1) int targetNum; cout : ; cintargetNum; / delete_Num(targetNum); couttargetName; delete_Name(targetName); coutendl; if(key = 3) while(1) menu_CMD(); / void delete_Num(int tarNum) int i; for(i = 1;i = stuNum;i+
11、) if(recordi.num = tarNum) / /1. /2. if(i = stuNum) cout : ”endl; show_Table(); coutrecordi.numtrecordi.name”trecordi。sext recordi。score0recordi.score1”t”recordi。score2; coutendl; coutendl : ”endl; show_Table(); for(int i = 1;i = stuNum 1;i+) coutrecordi。num”trecordi。name”t”recordi。sex; for(int j =
12、0;j SUBJECT_NUM;j+) coutt”recordi.scorej; coutendl; /* stuNum-; cout” stuNum; coutendl; / /2. if(i != stuNum) cout” : ”endl; show_Table(); coutrecordi.num”t”recordi。namet”recordi.sex”t recordi.score0trecordi.score1”t”recordi。score2; for(int j = i+1;j = stuNum;j+) recordj-1 = recordj; / coutendl; cou
13、t” : ”endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.numt”recordi.namet”recordi.sex; for(int j = 0;j SUBJECT_NUM;j+) cout”t”recordi。scorej; coutendl; /* stuNum-; cout” stuNum coutendl; */ stuNum-; cout ”stuNum coutendl; /*/void delete_Name(char tarName) int i; for(i = 1;i = stuNum;i+
14、) if(strcmp(recordi。name,tarName) = 0) / /1. /2. / if(i = stuNum) cout” : ”endl; show_Table(); coutrecordi。numt”recordi.nametrecordi.sex”t” recordi.score0recordi.score1”trecordi。score2; coutendl; coutendl : endl; show_Table(); for(int i = 1;i = stuNum 1;i+) coutrecordi.numtrecordi。namet”recordi。sex;
15、 for(int j = 0;j SUBJECT_NUM;j+) coutt”recordi.scorej; coutendl; / if(i != stuNum) cout : endl; show_Table(); coutrecordi.num”trecordi。name”trecordi.sex”t” recordi。score0”t”recordi.score1t”recordi。score2; / for(int j = i+1;j = stuNum;j+) recordj-1 = recordj; coutendl; / cout : endl; show_Table(); fo
16、r(int i = 1;i = stuNum1;i+) coutrecordi。num”t”recordi.name”t”recordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; coutendl; void delete_Name(char tarName) int i; for(i = 1;i = stuNum;i+) / /1。 /2. / if(strcmp(recordi.name,tarName) = 0) if(i = stuNum) cout” : endl; show_Table()
17、; coutrecordi。numt”recordi。name”trecordi。sex”t” recordi.score0”t”recordi。score1trecordi.score2; coutendl; cout” : endl; show_Table(); for(int i = 1;i = stuNum1;i+) coutrecordi.numt”recordi。nametrecordi。sex; for(int j = 0;j SUBJECT_NUM;j+) coutt”recordi。scorej; coutendl; /* stuNum-; cout stuNum ; cou
18、tendl; / / if(i != stuNum) cout endl; show_Table(); coutrecordi.numt”recordi.name”trecordi。sext”; coutrecordi。score0t”recordi.score1”trecordi.score2; coutendl; for(int j = i+1;j = stuNum;j+) recordj1 = recordj; /。 coutendl; cout” : ”endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.num”
19、trecordi。namet”recordi。sex; for(int j = 0;j SUBJECT_NUM;j+) cout”trecordi.scorej; coutendl; / stuNum-; cout stuNum coutendl; */ stuNum-; cout” stuNum ”; coutendl; /*/void Info_modify() cout : endl; cout1。 ”endl; cout2. endl; cout”3。 ”endl; void modifyRecord() int key; coutendl; Info_modify(); coutke
20、y;/ if(key = 1) int targetNum; cout : ; cintargetNum; modify_Num(targetNum); coutendl; /display(); / if(key = 2) char targetName20; cout : ”; cintargetName; modify_Name(targetName); coutendl; /display(); if(key = 3) while(1) menu_CMD(); /void modify_Num(int tarNum) int i; for(i = 1;i = stuNum;i+) if
21、(recordi.num = tarNum) coutendl” ”endl; cout : ; cinrecordi.num; coutrecordi。name; cout”; cinrecordi.sex; cout” recordi.score0; cout” subject1recordi。score1; cout subject2recordi.score2; void modify_Name(char tarName) int i; for(i = 1;i = stuNum;i+) if(strcmp(recordi.name,tarName) = 0) coutendl : ”recordi。num; cout : ”; cinrecordi.name; cout : ; cinrecordi.sex; cout ”subject0 : ”; cinrecordi。score0; cout subject1recordi.score1; cout ”
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1