-
Notifications
You must be signed in to change notification settings - Fork 0
/
成绩录入系统.c
85 lines (75 loc) · 1.87 KB
/
成绩录入系统.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <string.h>
#define MAX_STUDENTS 100
// 学生结构体
typedef struct {
char name[50];
int score;
} Student;
// 学生数组
Student students[MAX_STUDENTS];
// 当前数量
int numStudents = 0;
// 函数声明
void inputRecord();
void deleteRecord();
void findRecord();
void sortRecord();
void insertRecord();
void displayRecord();
int main() {
int choice;
do {
printf("1.成绩录入\n");
printf("2.成绩删除\n");
printf("3.成绩查找\n");
printf("4.成绩排序\n");
printf("5.成绩插入\n");
printf("6.退出成绩系统\n");
printf("请输入操作: ");
scanf("%d", &choice);
switch(choice) {
case 6:
printf("程序退出\n");
break;
case 1:
inputRecord();
break;
case 2:
// deleteRecord();
break;
case 3:
// findRecord();
break;
case 4:
// sortRecord();
break;
case 5:
// insertRecord();
break;
default:
printf("无效选项,请重新选择。\n");
}
} while(choice != 6);
return 0;
}
void inputRecord() {
if (numStudents == MAX_STUDENTS) {
printf("学生数量最大, 无法添加记录\n");
return;
}
Student newStudent;
printf("请输入姓名: ");
scanf("%s", newStudent.name);
printf("请输入成绩: ");
scanf("%d", &newStudent.score);
students[numStudents] = newStudent;
numStudents++;
printf("学生成绩记录添加成功\n");
}
void displayRecord() {
printf("姓名:成绩\n");
for (int i = 0; i < numStudents; i++) {
printf("%s, %d\n", students[i].name, students[i].score);
}
}