1、学生管理系统源代码#include#include#include#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();void modifyRecord()
2、;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 stuLEN + 1;/STUDENT
3、 *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; strcpy(
4、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); record3.sex
5、= F; record3.score0 = 85.0; record3.score1 = 90.0; record3.score2 = 95.0;*/* Info_modify(); int key; coutkey; if(key = 1) int targetNum; cout cintargetNum; modify_Num(targetNum); coutendl; display(); if(key = 2) char targetName20; couttargetName; modify_Name(targetName); coutendl; display(); if(key
6、= 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 couttsubject0tsubject1tsubject2; coutendl; void menu_CMD() int key; while(1) cout1. endl; cout2.
7、 endl; cout3. endl; cout4. endl; cout5. endl; cout6. endl; coutkey; while(1) if(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(); break; case 5: display(); break; case 6: quit()
8、; 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; coutchoi; if(choi = Y)|(choi = y) coutrecordstuNum.num; coutrecordstuNum.name; coutrecordstuNum.sex; int i;
9、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; cout1. endl; cout2. endl; cout3. endl;/ void deleteRecord() int key; coutendl; Info_delete(); coutkey; if(key = 1) in
10、t targetNum; couttargetNum; / delete_Num(targetNum); coutendl; if(key = 2) char targetName20; 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+) if(recordi.num = tarNum) / /1. /2. if(i = stuNum) cout : end
11、l; show_Table(); coutrecordi.numtrecordi.nametrecordi.sext recordi.score0recordi.score1trecordi.score2; coutendl; coutendl : endl; show_Table(); for(int i = 1;i = stuNum - 1;i+) coutrecordi.numtrecordi.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; /* stuNum-; cout
12、stuNum; coutendl; */ /2. if(i != stuNum) cout : endl; show_Table(); coutrecordi.numtrecordi.nametrecordi.sext recordi.score0trecordi.score1trecordi.score2; for(int j = i+1;j = stuNum;j+) recordj-1 = recordj; / coutendl; cout : endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.numtrecord
13、i.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; /* stuNum-; cout stuNum coutendl; */ stuNum-; cout stuNum coutendl; /*/void delete_Name(char tarName) int i; for(i = 1;i = stuNum;i+) if(strcmp(recordi.name,tarName) = 0) / /1. /2. / if(i = stuNum) cout : endl; show_T
14、able(); coutrecordi.numtrecordi.nametrecordi.sext recordi.score0recordi.score1trecordi.score2; coutendl; coutendl : endl; show_Table(); for(int i = 1;i = stuNum - 1;i+) coutrecordi.numtrecordi.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; / if(i != stuNum) cout : e
15、ndl; show_Table(); coutrecordi.numtrecordi.nametrecordi.sext recordi.score0trecordi.score1trecordi.score2; / for(int j = i+1;j = stuNum;j+) recordj-1 = recordj; coutendl; / cout : endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.numtrecordi.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM
16、;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(); coutrecordi.numtrecordi.nametrecordi.sext recordi.score0trecordi.score1trecordi.score2; coutendl; co
17、ut : endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.numtrecordi.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; /* stuNum-; cout stuNum ; coutendl; */ / if(i != stuNum) cout endl; show_Table(); coutrecordi.numtrecordi.nametrecordi.sext; coutrecordi.sc
18、ore0trecordi.score1trecordi.score2; coutendl; for(int j = i+1;j = stuNum;j+) recordj-1 = recordj; /. coutendl; cout : endl; show_Table(); for(int i = 1;i = stuNum-1;i+) coutrecordi.numtrecordi.nametrecordi.sex; for(int j = 0;j SUBJECT_NUM;j+) couttrecordi.scorej; coutendl; /* stuNum-; cout stuNum co
19、utendl; */ stuNum-; cout stuNum ; coutendl; /*/void Info_modify() cout : endl; cout1. endl; cout2. endl; cout3. endl; void modifyRecord() int key; coutendl; Info_modify(); coutkey;/ if(key = 1) int targetNum; couttargetNum; modify_Num(targetNum); coutendl; /display(); / if(key = 2) char targetName20
20、; couttargetName; 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(recordi.num = tarNum) coutendl endl; coutrecordi.num; coutrecordi.name; coutrecordi.sex; cout subject0recordi.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 : endl; coutrecordi.num; coutrecordi.name; coutrecordi.sex; cout subject0 :
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1