• 学生成绩管理系统


    单链表数据结构完成c++的学生成绩管理系统,此系统的具体功能如下:

    本人小萌新一个,遇到BUG是正常现象。并且类与对象写的不太理想。@-@

    写了一个Database存放所有数据,但这肯定浪费资源,你们看着改改吧。

    1. class DataBase
    2. {
    3. public:
    4. virtual void run();//多态
    5. void setID(int ID);
    6. void setName(string Name);
    7. void setSex(string Sex);
    8. void setChinese(double Chinese);
    9. void setMath(double Math);
    10. void setEnglish(double English);
    11. void setAverage(double Average);
    12. void setSum(double Sum);
    13. void setNews(string news);
    14. void setSolute(string solute);
    15. void setAccount(string A);
    16. void setPassword(string P);
    17. void setWordprotect(string W);
    18. void setNext(DataBase* next);
    19. int& getID();
    20. string& getName();
    21. string& getSex();
    22. double& getChinese();
    23. double& getMath();
    24. double& getEnglish();
    25. double& getAverage();
    26. double& getSum();
    27. string& getNews();
    28. string& getSolute();
    29. string& getAccount();
    30. string& getPassword();
    31. string& getWordprotect();
    32. DataBase* getNext();
    33. private:
    34. int ID = 0; //学号
    35. string Name = ""; //姓名
    36. string Sex = ""; //性别
    37. double Chinese = 0; //语文
    38. double Math = 0; //数学
    39. double English = 0; //英语
    40. double Average = 0; //平均分
    41. double Sum = 0; //总分
    42. string News = ""; //信息反馈
    43. string Solute = ""; //解决方案
    44. string account = ""; //账号
    45. string password = ""; //密码
    46. string wordprotect = "";//密保
    47. DataBase* next = nullptr;//指针域
    48. };
    1. 登录系统功能。

    1. 动画效果进入主界面,可选择教师端或学生端。

    1. void menu()
    2. {
    3. cout << "\t\t*********************************************" << endl;
    4. cout << "\t\t*****\t\t 1.教师端\t\t*****" << endl;
    5. cout << "\t\t*****\t\t 2.学生端\t\t*****" << endl;
    6. cout << "\t\t*****\t\t 0.退出 \t\t*****" << endl;
    7. cout << "\t\t*********************************************" << endl;
    8. }
    9. void Homepage()
    10. {
    11. WelcomeScreen();
    12. while (1)
    13. {
    14. system("cls");
    15. menu();
    16. cout << "\t\t选择:";
    17. DataBase* F = NULL;//多态进入不同界面操作
    18.         //这里也可以传对象实现多态
    19. string acc;
    20. cin >> acc;
    21. if (acc == "1") {
    22. F = new Teacher();
    23. F->run();//老师界面
    24. }
    25. else if (acc == "2") {
    26. F = new Student();
    27. F->run();//学生界面
    28. }
    29. else if (acc == "0") {
    30. F = new DataBase();
    31. F->run();//退出
    32. break;
    33. }
    34. else {
    35. continue;
    36. }
    37. }
    38. }
    39. int main()
    40. {
    41. Homepage();
    42. return 0;
    43. }
    1. 教师端:可以登录账号、注册账号、注销账号、找回注销的账号、修改密码以及退出。

    1. void menu1()
    2. {
    3. cout << "\t\t\t\t 教师端用户" << endl;
    4. cout << "\t\t*********************************************" << endl;
    5. cout << "\t\t*****\t\t 1.登录平台\t\t*****" << endl;
    6. cout << "\t\t*****\t\t 2.注册账号\t\t*****" << endl;
    7. cout << "\t\t*****\t\t 3.找回账号\t\t*****" << endl;
    8. cout << "\t\t*****\t\t 0.退出 \t\t*****" << endl;
    9. cout << "\t\t*********************************************" << endl;
    10. }
    11. void Teacher::run()
    12. {
    13. while (1)
    14. {
    15. system("cls");
    16. menu1();
    17. cout << "\t\t请选择:";
    18. string ffll = " ";
    19. cin >> ffll;
    20. if (ffll == "1") {
    21. cout << "\t\t***教师 登录***" << endl;
    22. login();
    23. }
    24. else if (ffll == "2") {
    25. cout << "\t\t***注册 账号***" << endl;
    26. regist();
    27. }
    28. else if (ffll == "3") {
    29. cout << "\t\t***找回 账号***" << endl;
    30. find();
    31. }
    32. else if (ffll == "0") {
    33. break;
    34. }
    35. else {
    36. continue;
    37. }
    38. }
    39. }
    40. void Teacher::login()
    41. {
    42. int pan = 1;//输入次数
    43. while (1) {
    44. system("cls");
    45. string ac = " ";
    46. char pa[10];
    47. char s;
    48. int j = 0;//确保数组从0开始
    49. while (1)
    50. {
    51. cout << "\t\t请输入账号(0退出):";
    52. cin >> ac;
    53. DataBase* ac1 = head1->getNext();
    54. while (ac1 != NULL)
    55. {
    56. if (ac == ac1->getAccount())break;
    57. ac1 = ac1->getNext();
    58. }
    59. if (ac1 == NULL) {
    60. cout << "\t\t未查寻到此账号!" << endl;
    61. }
    62. else {
    63. break;
    64. }
    65. if (ac == "0")break;
    66. }
    67. if (ac == "0")break;
    68. cout << "\t\t请输入密码:";
    69. while ((s = _getch()) != '\r')
    70. {
    71. if (s == '\b')
    72. {
    73. if (j > 0) {
    74. j--;//回删一位
    75. cout << "\b \b";
    76. }
    77. }
    78. else if (j < 8)
    79. { //控制密码位数
    80. pa[j] = s; //存入数组
    81. j++;
    82. putchar('*'); //用* 代替密码
    83. }
    84. }
    85. pa[j] = '\0';//避免乱码
    86. int ccvv = 0;
    87. DataBase* pp = head1->getNext();
    88. while (pp != NULL)
    89. {
    90. if ((pp->getAccount() == ac) && (pp->getPassword() == pa))
    91. {
    92. ccvv = 1;
    93. cout << endl << "\t\t验证正确" << endl;
    94. cout << endl;
    95. cout << "\t\t";
    96. for (int i = 0; i < 20; i++)
    97. {
    98. cout << ".";
    99. Sleep(50);
    100. }
    101. storage = pp->getAccount();//存一下账号
    102. operat();//进入教师界面
    103. break;
    104. }
    105. pp = pp->getNext();//遍历
    106. }
    107. if (pp == NULL)
    108. {
    109. cout << endl << "\t\t第" << pan++ << "次密码错误!" << endl;
    110. system("pause");
    111. }
    112. if (pan == 4) {
    113. cout << endl << "\t\t已输入3次,退出登录" << endl;
    114. system("pause");
    115. break;
    116. }
    117. if (ccvv == 1)break;
    118. }
    119. }
    120. void Teacher::regist()
    121. {
    122. while (1)
    123. {
    124. system("cls");
    125. DataBase* p = new DataBase();
    126. string account = " ", password = " ", wordprotect = "";
    127. cout << endl;
    128. cout << "\t\t*注册账号(0退出):";
    129. DataBase* p1 = head1->getNext();//查重
    130. cin >> account;
    131. if (account == "0")break;
    132. while (p1 != NULL)
    133. {
    134. if (p1->getAccount() == account)
    135. {
    136. cout << endl;
    137. cout << "\t\t此账号已存在!" << endl;
    138. system("pause");
    139. break;
    140. }
    141. p1 = p1->getNext();
    142. }
    143. if (p1 != NULL)continue;
    144. p->setAccount(account);
    145. while (1)
    146. {
    147. cout << "\t\t*设置密码(0退出):";
    148. cin >> password;
    149. if (password == "0")break;
    150. if (password.length() > 8) {
    151. cout << "\t\t密码超出八位!请再次设置" << endl;//确保密码只能设置8位
    152. continue;
    153. }
    154. break;
    155. }
    156. p->setPassword(password);
    157. cout << "\t\t*设置密保(0退出):";
    158. cin >> wordprotect;
    159. if (wordprotect == "0")break;
    160. p->setWordprotect(wordprotect);
    161. //头插
    162. p->setNext(head1->getNext());
    163. head1->setNext(p);
    164. write("E://1C//学生管理//rtea.txt", head1);
    165. cout << "\t\t*注册完成*" << endl;
    166. p = p->getNext();
    167. system("pause");
    168. break;
    169. }
    170. }
    171. int cratical = 0;//判断密码修改是否成功
    172. void Teacher::logout()
    173. {
    174. system("cls");
    175. string a = "", b = "";
    176. DataBase* s; //遍历注销账户
    177. DataBase* q;
    178. while (1)
    179. {
    180. cratical = 0;
    181. s = head1->getNext();
    182. q = head1;
    183. cout << "\t\t你的的账号:" << storage << endl;
    184. while (s != NULL)
    185. {
    186. if (s->getAccount() == storage)
    187. {
    188. break;
    189. }
    190. q = s;
    191. s = s->getNext();
    192. }
    193. if (s != NULL)break;
    194. }
    195. int ding = 1;
    196. while (1)
    197. {
    198. cratical = 0;
    199. cout << "\t 第 " << ding << " 次输入" << endl;
    200. ding++;
    201. cout << "\t\t请输入要注销账号的密码(0 退出):";
    202. cin >> a;
    203. if (a == "0")break;
    204. cout << endl;
    205. cout << "\t\t请输入要注销账号的密保(0 退出):";
    206. cin >> b;
    207. if (b == "0")break;
    208. cout << endl;
    209. int in1 = 1, in2 = 9;
    210. if (s->getPassword() == a)
    211. {
    212. in1 = 2;//密码
    213. }
    214. if (s->getWordprotect() == b)
    215. {
    216. in2 = 3;//密保
    217. }
    218. if (in1 + in2 == 5)
    219. {
    220. q->setNext(s->getNext());
    221. delete s;
    222. s = NULL;
    223. cout << endl << "\t\t删除成功!" << endl;
    224. write("E://1C//学生管理//rtea.txt", head1);
    225. cratical = 22;
    226. system("pause");
    227. }
    228. int in = 0;
    229. in = in1 + in2;
    230. if (in == 10)
    231. {
    232. cout << "\t\t密码和密保输入错误!" << endl;
    233. system("pause");
    234. }
    235. else if (in == 11)
    236. {
    237. cout << "\t\t密保输入错误!" << endl;
    238. system("pause");
    239. }
    240. else if (in == 4)
    241. {
    242. cout << "\t\t密码输入错误!" << endl;
    243. system("pause");
    244. }
    245. if (in == 5)
    246. {
    247. DataBase* c = new DataBase();//开辟空间 用于存注销的账号
    248. c->setAccount(storage);
    249. c->setPassword("0");//密码再行设置
    250. c->setWordprotect(b);
    251. c->setNext(headmode->getNext());
    252. headmode->setNext(c);
    253. write("E://1C//学生管理//rteafind.txt", headmode);
    254. c = c->getNext();
    255. break;
    256. }
    257. if (ding == 4) {
    258. cout << "\t\t已输入3次错误输入!强制退出" << endl;
    259. system("pause");
    260. break;
    261. }
    262. }
    263. }
    264. void Teacher::find()
    265. {
    266. while (1)
    267. {
    268. system("cls");
    269. cout << endl;
    270. cout << "\t\t请输入要找回的账号(0退出):";
    271. string a1 = " ";
    272. cin >> a1;
    273. if (a1 == "0")break;
    274. DataBase* f1 = headmode->getNext();
    275. DataBase* f2 = headmode;
    276. int o = 1;
    277. while (f1 != NULL)
    278. {
    279. if (a1 == f1->getAccount())
    280. {
    281. for (int i = 1; i < 5; i++)
    282. {
    283. if (i == 4)
    284. {
    285. cout << "\t输入3次全部错误退出验证!" << endl;
    286. o = 3;
    287. system("pause");
    288. break;
    289. }
    290. cout << "\t第 " << i << " 次输入" << endl;
    291. cout << "\t请输入密保:";
    292. string a2;
    293. cin >> a2;
    294. if (a2 == f1->getWordprotect()) {
    295. cout << "\t密保确认成功!" << endl;
    296. cout << "\t已找回账号" << endl;
    297. //找回密码 写入rtea文件
    298. DataBase* p11 = new DataBase();
    299. p11->setAccount(a1);
    300. cout << "\t重新设置密码:";
    301. string ma = " ";
    302. cin >> ma;
    303. p11->setPassword(ma);
    304. cout << "\t重新设置密保:";
    305. string pr = " ";
    306. cin >> pr;
    307. p11->setWordprotect(pr);
    308. p11->setNext(head1->getNext());
    309. head1->setNext(p11);
    310. write("E://1C//学生管理//rtea.txt", head1);
    311. o = 3;
    312. system("pause");
    313. break;
    314. }
    315. else {
    316. cout << "\t输入错误!" << endl;
    317. }
    318. }
    319. }
    320. if (o == 3)
    321. {
    322. //删除rteafind 中的账号信息
    323. f2->setNext(f1->getNext());
    324. delete f1;
    325. f1 = NULL;
    326. write("E://1C//学生管理//rteafind.txt", headmode);
    327. break;
    328. }
    329. f2 = f1;
    330. f1 = f1->getNext();
    331. }
    332. if (o == 3)break;
    333. if (f1 == NULL)
    334. {
    335. cout << "\t 查询无此账号!" << endl;
    336. system("pause");
    337. }
    338. }
    339. }
    340. void Teacher::modify()
    341. {
    342. int chi = 0;
    343. while (1)
    344. {
    345. cratical = 0;
    346. system("cls");
    347. cout << endl;
    348. cout << "\t\t你的账号:" << storage << endl;
    349. cout << "请输入密保方可修改密码:";
    350. string mi;
    351. cin >> mi;
    352. DataBase* move = head1->getNext();
    353. while (move != NULL)
    354. {
    355. if (move->getWordprotect() == mi && move->getAccount() == storage)
    356. {
    357. cout << "\t\t原密码:" << move->getPassword() << endl;
    358. string llop;
    359. cout << "\t\t新密码:";
    360. cin >> llop;
    361. move->setPassword(llop);
    362. write("E://1C//学生管理//rtea.txt", head1);
    363. cratical = 21;
    364. cout << endl << "\t\t修改完成!";
    365. system("pause");
    366. break;
    367. }
    368. move = move->getNext();
    369. }
    370. if (move == NULL)
    371. {
    372. cout << endl << "\t第" << ++chi << "次密保输入错误!" << endl;
    373. system("pause");
    374. }
    375. else {
    376. break;
    377. }
    378. if (chi == 3)
    379. {
    380. cout << "\t\t三次输入全部错误!马上退出" << endl;
    381. system("pause");
    382. break;
    383. }
    384. }
    385. }
    1. 学生端:可以登录账号、注册账号、注销账号、修改密码以及退出。与教师端大同小异。

    1. 教师端功能

    1. #pragma once
    2. #include"DataBase.h"
    3. class Teacher : public DataBase
    4. {
    5. private: //学生不可继承的功能
    6. bool Turnitin(int ID);//查重
    7. void CreateDataBase(); //添加学生
    8. void Sort(); //按成绩排序
    9. void M1odify(); //修改学生信息
    10. void Delete(); //删除学生信息
    11. public:
    12. Teacher();// head节点
    13. ~Teacher();
    14. virtual void run();
    15. void login(); //账号登录
    16. void regist(); //账号注册
    17. void logout(); //账号注销
    18. void find(); //账号找回
    19. void modify(); //修改密码
    20. void read(const char* file, DataBase* head);
    21. void write(const char* file, DataBase* head);
    22. void operat(); //运转器
    23. void Search(); //查找学生信息
    24. void Show(); //显示全部学生信息
    25. void Back(); //学生信息反馈
    26. void Readfile(const char* Filename);//读文件
    27. void Writefile(const char* Filename);//写文件
    28. };
    1. 添加学生信息:可录入学号、姓名、性别、语文、数学、英语等相关信息和成绩,并且由算法实现平均分、总分存入链表写入文件等的操作。

    1. bool Teacher::Turnitin(int ID)// 学号查重
    2. {
    3. DataBase* h = head->getNext();
    4. while (h != NULL)
    5. {
    6. if (h->getID() == ID)
    7. {
    8. cout << "学号 " << ID << " 重复" << endl;
    9. cout << "请输入新的学号:";
    10. return false;
    11. }
    12. h = h->getNext();
    13. }
    14. return true;
    15. }
    16. void Teacher::CreateDataBase() //添加新的学生信息
    17. {
    18. system("cls");
    19. DataBase* p = head->getNext();
    20. cout << "\t添加学生数量:";
    21. int n = 0;
    22. cin >> n;
    23. for (int i = 0; i < n; i++)
    24. {
    25. p = new DataBase();
    26. cout << "请输入第" << i + 1 << "位:" << endl;
    27. int ID = 0;
    28. string Name = " ", Sex = " ";
    29. double Chinese = 0, Math = 0, English = 0, Average = 0, Sum = 0;
    30. cout << " 学号:";
    31. cin >> ID;
    32. while (1)
    33. {
    34. if (!Turnitin(ID))
    35. {
    36. cin >> ID;
    37. }
    38. else {
    39. break;
    40. }
    41. }
    42. p->setID(ID);
    43. cout << " 姓名:";
    44. cin >> Name;
    45. p->setName(Name);
    46. cout << " 性别:";
    47. while (1)
    48. {
    49. cin >> Sex;
    50. if (Sex == "男" || Sex == "女")
    51. {
    52. break;
    53. }
    54. else
    55. {
    56. cout << "只能输入男/女\t请再次输入:";
    57. }
    58. }
    59. p->setSex(Sex);
    60. cout << " 语文:";
    61. cin >> Chinese;
    62. p->setChinese(Chinese);
    63. cout << " 数学:";
    64. cin >> Math;
    65. p->setMath(Math);
    66. cout << " 英语:";
    67. cin >> English;
    68. p->setEnglish(English);
    69. p->getSum() = Chinese + Math + English;
    70. p->getAverage() = p->getSum() / 3.0;
    71. //newDataBase->next = temp->next;//头插法
    72. //反馈信息
    73. p->setNews("无");//无反馈信息
    74. p->setSolute("无");//无解决方案
    75. p->setNext(head->getNext());
    76. head->setNext(p);
    77. Writefile("E://1C//学生管理//1.txt");
    78. cout << "添加完成!" << endl;
    79. p = p->getNext();
    80. }
    81. system("pause");
    82. system("cls");
    83. }
    1. 显示学生信息:可显示全部学生信息,并且每10个人会翻一下页及统计总人数。

    1. void Teacher::Show()//显示全部信息
    2. {
    3. system("cls");
    4. cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    5. DataBase* o = head->getNext(); //遍历得到总人数
    6. DataBase* h = head->getNext(); //遍历显示每个人的所有信息
    7. int sd = 0, ss = 1;
    8. while (o != NULL)
    9. {
    10. sd = sd + 1;
    11. o = o->getNext();
    12. }
    13. int i = 1;
    14. while (h != NULL)
    15. {
    16. if (ss > 0 && ss < 11)
    17. {
    18. ss = ss + 1;
    19. h->getSum() = h->getChinese() + h->getEnglish() + h->getMath();
    20. h->getAverage() = h->getSum() / 3.0;
    21. cout << h->getID() << "\t" << h->getName() << "\t" << h->getSex() << "\t";
    22. cout << fixed << setprecision(2) << h->getChinese() << "\t" << h->getMath() << "\t" << h->getEnglish() << "\t" << h->getAverage() << "\t" << h->getSum() << endl;
    23. }
    24. else {
    25. ss = 1;
    26. cout << "\t第[" << i++ << "/10人]页" << endl;
    27. system("pause");
    28. system("cls");
    29. cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    30. continue;
    31. }
    32. h = h->getNext();
    33. }
    34. cout << "第[" << i++ << "/10人]页" << endl;
    35. cout << "参加考试共有【" << sd << "】个学生" << endl;
    36. system("pause");
    37. }
    1. 修改学生信息:修改操作。

    1. void Teacher::M1odify()//修改
    2. {
    3. while (1)
    4. {
    5. system("cls");
    6. DataBase* p1 = head->getNext();//按学号修改
    7. DataBase* p2 = head->getNext();//修改学号
    8. cout << "\t\t1、请输入学号:" << endl;
    9. cout << "\t\t2、修改学号" << endl;
    10. cout << "\t\t0、退出" << endl;
    11. cout << "\t选择:";
    12. int ch;
    13. cin >> ch;
    14. if (ch==1) //判断学号
    15. {
    16. int ID1 = 0;
    17. cout << "请输入你的学号";
    18. cin >> ID1;
    19. int q1 = 1;
    20. while (p1 != NULL)//遍历
    21. {
    22. if (p1->getID() == ID1)
    23. {
    24. q1 = 0;
    25. cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    26. cout << p1->getID() << "\t" << p1->getName() << "\t" << p1->getSex() << "\t";
    27. cout << fixed << setprecision(2) << p1->getChinese() << "\t" << p1->getMath() << "\t" << p1->getEnglish() << "\t" << p1->getAverage() << "\t" << p1->getSum() << endl;
    28. while (1) { //多次修改
    29. cout << "(可修改姓名、性别、语文、数学、英语 按0可取消修改)" << endl;
    30. char ccc[100];
    31. cout << "选择:";
    32. cin >> ccc;
    33. if (!strcmp(ccc, "姓名"))
    34. {
    35. cout << "修改为:";
    36. string name;
    37. cin >> name;
    38. p1->getName() = name;
    39. cout << "\t姓名修改成功!" << endl;
    40. }
    41. else if (!strcmp(ccc, "性别"))
    42. {
    43. cout << "修改为:";
    44. string sex;
    45. while (1)
    46. {
    47. cin >> sex;
    48. if (sex == "男" || sex == "女")
    49. {
    50. break;
    51. }
    52. else
    53. {
    54. cout << "只能输入男/女\t请再次输入:";
    55. }
    56. }
    57. p1->getSex() = sex;
    58. cout << "\t性别修改成功!" << endl;
    59. }
    60. else if (!strcmp(ccc, "语文"))
    61. {
    62. cout << "修改为:";
    63. double chin = 0;
    64. cin >> chin;
    65. p1->getChinese() = chin;
    66. p1->getSum() = chin + p1->getMath() + p1->getEnglish();
    67. p1->getAverage() = p1->getSum() / 3.0;
    68. cout << "\t语文成绩修改成功!" << endl;
    69. }
    70. else if (!strcmp(ccc, "数学"))
    71. {
    72. cout << "修改为:";
    73. double ma = 0;
    74. cin >> ma;
    75. p1->getMath() = ma;
    76. p1->getSum() = ma + p1->getChinese() + p1->getEnglish();
    77. p1->getAverage() = p1->getSum() / 3.0;
    78. cout << "\t数学成绩修改成功!" << endl;
    79. }
    80. else if (!strcmp(ccc, "英语"))
    81. {
    82. cout << "修改为:";
    83. double eng = 0;
    84. cin >> eng;
    85. p1->getEnglish() = eng;
    86. p1->getSum() = eng + p1->getMath() + p1->getChinese();
    87. p1->getAverage() = p1->getSum() / 3.0;
    88. cout << "\t英语成绩修改成功!" << endl;
    89. }
    90. else if (!strcmp(ccc, "0"))
    91. {
    92. break;
    93. }
    94. }
    95. }
    96. p1 = p1->getNext();
    97. }
    98. if(q1==1)
    99. {
    100. cout << "\t\t无此学号的学生!" << endl;
    101. system("pause");
    102. }
    103. Writefile("E://1C//学生管理//1.txt");
    104. }
    105. else if (ch==2)
    106. {
    107. cout << "选择要修改的学号:";
    108. int xu, xv = 0;//学号
    109. cin >> xu;
    110. while (p2 != NULL)
    111. {
    112. if (p2->getID() == xu)
    113. {
    114. cout << "修改为:";
    115. int changexu;
    116. cin >> changexu;
    117. DataBase* q1 = head->getNext();
    118. int y = 0;
    119. while (q1 != NULL)
    120. {
    121. if (q1->getID() == changexu)
    122. {
    123. y = 1;
    124. cout << "已有此学号的信息,不可修改!" << endl;
    125. break;
    126. }
    127. q1 = q1->getNext();
    128. }
    129. if (y == 1)break;
    130. p2->getID() = changexu;
    131. cout << "\t修改成功!" << endl;
    132. Writefile("E://1C//学生管理//1.txt");
    133. cout << "学号已经修改为" << p2->getID() << " 请妥善保管" << endl;
    134. break;
    135. }
    136. p2 = p2->getNext();
    137. }
    138. if (p2 == NULL)
    139. {
    140. cout << "没有此学号" << endl;
    141. }
    142. system("pause");
    143. }
    144. else if (ch==0)
    145. {
    146. break;
    147. }
    148. }
    149. }
    1. 查找学生信息:对学生查找。

    1. void Teacher::Search()
    2. {
    3. while (1)
    4. {
    5. DataBase* pM = head->getNext(); //按姓名
    6. DataBase* pN = head->getNext(); //按学号
    7. system("cls");
    8. cout << "\t\t1、按学号查找:" << endl;
    9. cout << "\t\t2、按姓名查找:" << endl;
    10. cout << "\t\t0、退出:" << endl;
    11. cout << "\t选择:";
    12. char choice[100] = { 0 };
    13. gets_s(choice);
    14. if (!strcmp(choice, "2"))
    15. {
    16. cout << "请输入你的姓名:" << endl;
    17. string Name;
    18. cin >> Name;
    19. int cc = 0;
    20. cout << "序号\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    21. while (pM != NULL)
    22. {
    23. if (pM->getName() == Name)
    24. {
    25. cc++;
    26. cout << cc << "\t" << pM->getID() << "\t" << pM->getName() << "\t" << pM->getSex() << "\t";
    27. cout << fixed << setprecision(2) << pM->getChinese() << "\t" << pM->getMath() << "\t" << pM->getEnglish() << "\t" << pM->getAverage() << "\t" << pM->getSum() << endl;
    28. }
    29. pM = pM->getNext();
    30. }
    31. cout << "已查到以上[" << cc << "]个学生" << endl;
    32. system("pause");
    33. }
    34. else if (!strcmp(choice, "1"))
    35. {
    36. cout << "请输入你的学号:" << endl;
    37. int ID;
    38. cin >> ID;
    39. int cc = 0;
    40. while (pN != NULL)
    41. {
    42. if (pN->getID() == ID)
    43. {
    44. cc++;
    45. cout << "序号\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    46. cout << cc << "\t" << pN->getID() << "\t" << pN->getName() << "\t" << pN->getSex() << "\t";
    47. cout << fixed << setprecision(2) << pN->getChinese() << "\t" << pN->getMath() << "\t" << pN->getEnglish() << "\t" << pN->getAverage() << "\t" << pN->getSum() << endl;
    48. break;
    49. }
    50. pN = pN->getNext();
    51. }
    52. if (pN == NULL)
    53. {
    54. cout << "没有学号为 " << ID << " 的学生" << endl;
    55. }
    56. system("pause");
    57. }
    58. else if (!strcmp(choice, "0"))
    59. {
    60. break;
    61. }
    62. }
    63. }
    1. 删除学生信息:删除学生各个数据。

    1. void Teacher::Delete()
    2. {
    3. while (1)
    4. {
    5. system("cls");
    6. DataBase* p = head->getNext();
    7. DataBase* q = head->getNext();
    8. DataBase* pq = head;
    9. int ji = 0;
    10. cout << "学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    11. while (p != NULL)
    12. {
    13. ji++;
    14. cout << p->getID() << "\t" << p->getName() << "\t" << p->getSex() << "\t";
    15. cout << fixed << setprecision(2) << p->getChinese() << "\t" << p->getMath() << "\t" << p->getEnglish() << "\t" << p->getAverage() << "\t" << p->getSum() << endl;
    16. p = p->getNext();
    17. }
    18. cout << "\t\t共计【" << ji << "】名学生" << endl;
    19. cout << "\t\t输入学号便可删除( 0 退出):";
    20. int dd = 0, pan = 1;
    21. cin >> dd;
    22. while (q != NULL)
    23. {
    24. if (dd == 0)
    25. {
    26. cout << "\t\t退出成功!" << endl;
    27. break;
    28. }
    29. if (q->getID() == dd)
    30. {
    31. pq->setNext(q->getNext());
    32. delete q;
    33. q = NULL;
    34. cout << "\t\t删除成功!" << endl;
    35. Writefile("E://1C//学生管理//1.txt");
    36. pan = 0;
    37. break;
    38. }
    39. pq = q;
    40. q = q->getNext();
    41. }
    42. if (dd == 0)break;
    43. if (pan == 1)
    44. {
    45. cout << "\t\t未查询到此学号!" << endl;
    46. }
    47. system("pause");
    48. }
    49. }
    1. 排序操作:可对语文、数学、英语等成绩单独操作,也可对平均分、总分排序。

    1. void sortMachine(int i) //排序机,若只有一个人无法排序
    2. {
    3. DataBase* p, * q, * temp;
    4. temp = head;
    5. p = temp->getNext()->getNext();
    6. temp->getNext()->setNext(NULL);
    7. q = p->getNext();
    8. while (1)
    9. {
    10. if (head->getNext() == NULL)break;
    11. if (i == 1)//语文
    12. {
    13. while (temp->getNext() != NULL && temp->getNext()->getChinese() > p->getChinese())
    14. temp = temp->getNext();//如果满足条件后移
    15. }
    16. else if (i == 2)//数学
    17. {
    18. while (temp->getNext() != NULL && temp->getNext()->getMath() > p->getMath())
    19. temp = temp->getNext();
    20. }
    21. else if (i == 3)//英语
    22. {
    23. while (temp->getNext() != NULL && temp->getNext()->getEnglish() > p->getEnglish())
    24. temp = temp->getNext();
    25. }
    26. else if (i == 4)//平均分
    27. {
    28. while (temp->getNext() != NULL && temp->getNext()->getAverage() > p->getAverage())
    29. temp = temp->getNext();
    30. }
    31. else if (i == 5)//总分
    32. {
    33. while (temp->getNext() != NULL && temp->getNext()->getSum() > p->getSum())
    34. temp = temp->getNext();
    35. }
    36. p->setNext(temp->getNext());
    37. temp->setNext(p);//temp一直指向p的下一个
    38. temp = head;//从头遍历
    39. p = q;//p后移一个
    40. if (q == NULL)break;
    41. q = q->getNext();
    42. }
    43. DataBase* o = head->getNext();
    44. int c = 0;
    45. cout << "名次\t学号\t姓名\t性别\t语文\t数学\t英语\t平均分\t总分" << endl;
    46. while (o != NULL)
    47. {
    48. c++;
    49. cout << c << "\t" << o->getID() << "\t" << o->getName() << "\t" << o->getSex() << "\t";
    50. cout << fixed << setprecision(2) << o->getChinese() << "\t" << o->getMath() << "\t" << o->getEnglish() << "\t" << o->getAverage() << "\t" << o->getSum() << endl;
    51. o = o->getNext();
    52. }
    53. system("pause");
    54. }
    55. void Teacher::Sort() //按成绩排序
    56. {
    57. while (1)
    58. {
    59. system("cls");
    60. DataBase* s1 = head->getNext();
    61. DataBase* s2 = head;
    62. cout << "\t\t1、按语文排序" << endl;
    63. cout << "\t\t2、按数学排序" << endl;
    64. cout << "\t\t3、按英语排序" << endl;
    65. cout << "\t\t4、按平均分排序" << endl;
    66. cout << "\t\t5、按总成绩排序" << endl;
    67. cout << "\t\t0、退出" << endl;
    68. cout << "\t\t选择:";
    69. int chose = 0;
    70. cin >> chose;
    71. if (chose == 1)
    72. {
    73. sortMachine(chose);
    74. }
    75. else if (chose == 2)
    76. {
    77. sortMachine(chose);
    78. }
    79. else if (chose == 3)
    80. {
    81. sortMachine(chose);
    82. }
    83. else if (chose == 4)
    84. {
    85. sortMachine(chose);
    86. }
    87. else if (chose == 5)
    88. {
    89. sortMachine(chose);
    90. }
    91. else if (chose == 0)
    92. {
    93. break;
    94. }
    95. }
    96. }
    1. 学生信息反馈:学生端可发出信息教师端接收,并且可阅览反馈的问题,教师端可写下解决办法,传入学生端。

    1. void Teacher::Back()
    2. {
    3. while (1)
    4. {
    5. system("cls");
    6. DataBase* s9 = head->getNext();
    7. DataBase* s6 = head->getNext();
    8. int ssp = 0;
    9. cout << "序号\t学号\t姓名\t性别\t反馈信息\t解决方案" << endl;
    10. while (s9 != NULL)
    11. {
    12. if (s9->getNews() != "无")
    13. {
    14. cout << ++ssp << "\t" << s9->getID() << "\t" << s9->getName() << "\t" << s9->getSex() << "\t" << s9->getNews() << "\t\t" << s9->getSolute() << endl;
    15. }
    16. s9= s9->getNext();
    17. }
    18. cout << "\t\t共计【" << ssp << "】条信息" << endl;
    19. if (ssp == 0) {
    20. cout << "\t\t无信息反馈!" << endl;
    21. system("pause");
    22. break;
    23. }
    24. cout << "\t\t输入学号回复信息( 0 退出):";
    25. int dd = 0 ;
    26. cin >> dd;
    27. if (dd == 0)break;
    28. while (s6 != NULL)
    29. {
    30. if (s6->getID() == dd)
    31. {
    32. break;
    33. }
    34. s6 = s6->getNext();
    35. }
    36. if (s6 == NULL)
    37. {
    38. cout << "\t\t未查询到此学号!" << endl;
    39. system("pause");
    40. continue;
    41. }
    42. cout << "\t\t请写回复信息:";
    43. cin >> s6->getSolute();
    44. cout << "\t\t回复完毕!" << endl;
    45. Writefile("E://1C//学生管理//1.txt");
    46. cout << "\t\t继续回复按1,退出按0" << endl;
    47. string ci = " ";
    48. while (1)
    49. {
    50. cout << "\t\t选择:";
    51. cin >> ci;
    52. if (ci == "0")break;
    53. if (ci == "1")break;
    54. cout << "\t\t无此选项!重选:" << endl;
    55. }
    56. if (ci == "0")break;
    57. system("pause");
    58. }
    59. }
    1. 退出教师界面。

    1. 学生端功能实现

    1. 查看全校成绩:查看全校成绩,按总分排序。

    1. 查看个人成绩:搜索个人的信息。

    1. 查看个人能力:系统根据所得成绩分析你的能力,以及显示各科排名及总成绩排名。

    1. 递交反馈信息:写反馈信息发送到教师端。

    1. 查看反馈信息:可看自己提出的问题是否解决,以及其他人的反馈信息。

    1. 退出学生界面。

  • 相关阅读:
    打字速度测试,生成您的打字速度证书?
    vue-admin-better前端页面-菜单-权限配置
    在ubuntu中安装Ruby on Rails的常用命令
    实现Element Select选择器滚动加载
    驱动开发 基于gpio子系统来实现对stm32开发板的led亮灭实现,附加定时器实现一秒亮灭(软件:vscode)
    Linux操作系统作业
    html - 如何在 html5 中居中画布
    JS简易计算器
    二分搜索树节点的查找(Java 实例代码)
    猿创征文|Python快速刷题网站——牛客网 数据分析篇(十三)
  • 原文地址:https://blog.csdn.net/m0_73337964/article/details/128760922