首页 / C++ / c++学生管理系统(二)
c++学生管理系统(二)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c++学生管理系统(二),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3768字,纯文字阅读大概需要6分钟。
内容图文
![c++学生管理系统(二)](/upload/InfoBanner/zyjiaocheng/608/dd69c367325e4d898a057d26ad32ae53.jpg)
新建student.cpp,实现student.h声明的所有函数
1 #include<iostream> 2 #include "student.h" 3 4 using namespace std; 5 6 void displayStudent(Student *stu_head) { 7 Student *curNode = stu_head; 8 cout << "学号\t\t姓名\t\t性别\t年龄\t成绩" << endl; 9 while(curNode != NULL) { 10 cout << curNode->no << "\t\t" << curNode->name << "\t\t" << curNode->sex << "\t" << curNode->age << "\t" << curNode->score << endl; 11 curNode = curNode->next; 12 } 13 } 14 15 Student* searchStudent(Student *stu_head) { 16 string sno; 17 cout << "please input student no:" << endl; 18 cin >> sno; 19 Student *curNode = stu_head; 20 cout << "学号\t\t姓名\t\t性别\t年龄\t成绩" << endl; 21 while(curNode != NULL) { 22 if(curNode->no == sno) { 23 cout << curNode->no << "\t\t" << curNode->name << "\t\t" << curNode->sex << "\t" << curNode->age << "\t" << curNode->score << endl; 24 break; 25 } else { 26 if(curNode->next != NULL){ 27 curNode = curNode->next; 28 } else { 29 break; 30 } 31 } 32 } 33 return curNode; 34 } 35 36 Student* addStudent(Student *stu_head) { 37 Student *student = new Student; 38 cout << "input no:" << endl; 39 cin >> student->no; 40 cout << "input name:" << endl; 41 cin >> student->name; 42 cout << "input age:" << endl; 43 cin >> student->age; 44 cout << "input sex:" << endl; 45 cin >> student->sex; 46 cout << "input score:" << endl; 47 cin >> student->score; 48 49 student->next = NULL; 50 51 if (stu_head == NULL){ 52 stu_head = student; 53 } else { 54 student->next = stu_head->next; 55 stu_head->next = student; 56 } 57 return stu_head; 58 } 59 60 void modStudent(Student *stu_head) { 61 Student *curNode = searchStudent(stu_head); 62 if(curNode != NULL) { 63 cout << "input your modify select:" << endl; 64 cout << "1)name" << endl; 65 cout << "2)sex" << endl; 66 cout << "3)age" << endl; 67 cout << "4)score" << endl; 68 int key; 69 cin >> key; 70 switch (key) 71 { 72 case 1: 73 cout << "input name:" << endl; 74 cin >> curNode->name; 75 break; 76 case 2: 77 cout << "input sex:" << endl; 78 cin >> curNode->sex; 79 break; 80 case 3: 81 cout << "input age:" << endl; 82 cin >> curNode->age; 83 break; 84 case 4: 85 cout << "input score:" << endl; 86 cin >> curNode->score; 87 break; 88 default: 89 break; 90 } 91 cout << "学号\t\t姓名\t\t性别\t年龄\t成绩" << endl; 92 cout << curNode->no << "\t\t" << curNode->name << "\t\t" << curNode->sex << "\t" << curNode->age << "\t" << curNode->score << endl; 93 } 94 95 } 96 97 Student* delStudentByNo(Student *stu_head, string sno) { 98 Student *curNode = stu_head; 99 if(stu_head != NULL && stu_head->no == sno) { 100 if(stu_head->next != NULL) { 101 Student* delNode = stu_head; 102 stu_head = stu_head->next; 103 delNode = NULL; 104 } else { 105 stu_head = NULL; 106 } 107 108 } 109 110 while(curNode != NULL && curNode->next != NULL){ 111 if(curNode->next->no == sno){ 112 Student *delNode = NULL; 113 delNode = curNode->next; 114 curNode->next = curNode->next->next; 115 delNode = NULL; 116 break; 117 } else { 118 curNode = curNode->next; 119 } 120 // displayStudent(stu_head); 121 } 122 return stu_head; 123 }
内容总结
以上是互联网集市为您收集整理的c++学生管理系统(二)全部内容,希望文章能够帮你解决c++学生管理系统(二)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。