c语言程序设计学生管理系统
时间: 2023-12-26 19:27:35 浏览: 42
以下是一个简单的C语言程序设计学生管理系统的示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STUDENTS 100
struct Student {
char name[50];
int age;
int grade;
};
struct StudentManagementSystem {
struct Student students[MAX_STUDENTS];
int numStudents;
};
void addStudent(struct StudentManagementSystem* system, const char* name, int age, int grade) {
if (system->numStudents >= MAX_STUDENTS) {
printf("Student database is full.\n");
return;
}
struct Student newStudent;
strcpy(newStudent.name, name);
newStudent.age = age;
newStudent.grade = grade;
system->students[system->numStudents] = newStudent;
system->numStudents++;
}
void printStudents(struct StudentManagementSystem* system) {
printf("Student List:\n");
for (int i = 0; i < system->numStudents; i++) {
printf("Name: %s, Age: %d, Grade: %d\n", system->students[i].name, system->students[i].age, system->students[i].grade);
}
}
int main() {
struct StudentManagementSystem system;
system.numStudents = 0;
addStudent(&system, "Alice", 20, 85);
addStudent(&system, "Bob", 21, 90);
addStudent(&system, "Charlie", 19, 75);
printStudents(&system);
return 0;
}
```
这个程序设计了一个学生管理系统,可以添加学生信息并打印学生列表。程序使用了结构体来表示学生的信息,通过`addStudent`函数可以添加学生,通过`printStudents`函数可以打印学生列表。
相关推荐
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)