学生信息管理系统c++
时间: 2023-06-29 22:17:52 浏览: 44
好的,你想了解关于学生信息管理系统的C++实现。这个系统主要用于管理学生的基本信息,包括姓名、学号、班级、成绩等,同时还可以进行添加、删除、修改和查询等操作。
下面是一个简单的C++代码示例,实现了学生信息的添加、查询和显示功能:
```cpp
#include <iostream>
#include <string>
using namespace std;
struct Student {
string name;
string id;
string cls;
float score;
};
void addStudent(Student stu[], int &num) {
cout << "请输入学生姓名:" << endl;
cin >> stu[num].name;
cout << "请输入学号:" << endl;
cin >> stu[num].id;
cout << "请输入班级:" << endl;
cin >> stu[num].cls;
cout << "请输入成绩:" << endl;
cin >> stu[num].score;
num++;
cout << "添加成功!" << endl;
}
void findStudent(Student stu[], int num) {
string id;
cout << "请输入要查找的学生学号:" << endl;
cin >> id;
for (int i = 0; i < num; i++) {
if (stu[i].id == id) {
cout << "姓名:" << stu[i].name << endl;
cout << "学号:" << stu[i].id << endl;
cout << "班级:" << stu[i].cls << endl;
cout << "成绩:" << stu[i].score << endl;
return;
}
}
cout << "没有找到该学生!" << endl;
}
void showAll(Student stu[], int num) {
for (int i = 0; i < num; i++) {
cout << "姓名:" << stu[i].name << endl;
cout << "学号:" << stu[i].id << endl;
cout << "班级:" << stu[i].cls << endl;
cout << "成绩:" << stu[i].score << endl;
}
}
int main() {
Student stu[100];
int num = 0;
int choice;
while (1) {
cout << "请选择操作:" << endl;
cout << "1. 添加学生信息" << endl;
cout << "2. 查找学生信息" << endl;
cout << "3. 显示所有学生信息" << endl;
cout << "4. 退出" << endl;
cin >> choice;
switch (choice) {
case 1:
addStudent(stu, num);
break;
case 2:
findStudent(stu, num);
break;
case 3:
showAll(stu, num);
break;
case 4:
return 0;
default:
cout << "无效操作!" << endl;
}
}
return 0;
}
```
这个程序使用了结构体来定义学生信息,使用数组来保存多个学生的信息,通过循环来实现不断的添加、查询和显示操作。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)