用C语言写一个简单的学生信息管理系统
时间: 2023-10-16 08:08:17 浏览: 41
当然可以!下面是一个简单的示例,演示了如何使用C语言编写一个学生信息管理系统:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENTS 100
typedef struct {
char name[50];
int age;
float score;
} Student;
int main() {
Student students[MAX_STUDENTS];
int numStudents = 0;
int choice;
do {
printf("\nStudent Information Management System\n");
printf("1. Add Student\n");
printf("2. Display All Students\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
if (numStudents >= MAX_STUDENTS) {
printf("Maximum number of students reached!\n");
break;
}
printf("\nAdd Student\n");
printf("Enter name: ");
scanf("%s", students[numStudents].name);
printf("Enter age: ");
scanf("%d", &students[numStudents].age);
printf("Enter score: ");
scanf("%f", &students[numStudents].score);
numStudents++;
break;
case 2:
if (numStudents == 0) {
printf("No students to display!\n");
break;
}
printf("\nAll Students\n");
for (int i = 0; i < numStudents; i++) {
printf("Name: %s, Age: %d, Score: %.2f\n", students[i].name, students[i].age, students[i].score);
}
break;
case 3:
printf("Exiting the program. Goodbye!\n");
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
} while (1);
return 0;
}
```
这个简单的学生信息管理系统允许你添加学生的姓名、年龄和分数,并可以显示已添加的所有学生信息。你可以根据自己的需求进行扩展和修改。记得在编译和运行之前,确保你已经安装了C语言的开发环境。希望对你有所帮助!
相关推荐
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)