|
|
|
@ -1,70 +0,0 @@
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include<time.h>
|
|
|
|
|
#include "menu.h"
|
|
|
|
|
|
|
|
|
|
#define MAX_INPUT_LENGTH 10
|
|
|
|
|
|
|
|
|
|
void displayMenu() {
|
|
|
|
|
printf(" 1.Input\n");
|
|
|
|
|
printf(" 2.Output\n");
|
|
|
|
|
printf(" 3.Insert\n");
|
|
|
|
|
printf(" 4.Delete\n");
|
|
|
|
|
printf(" 5.Modify\n");
|
|
|
|
|
printf(" 6.Query\n");
|
|
|
|
|
printf(" 7.Quit\n");
|
|
|
|
|
printf("Please input your option: \n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void inputStudentInfo(Student students[], int* count) {
|
|
|
|
|
int numToInput;
|
|
|
|
|
char input[10];
|
|
|
|
|
printf("请输入要添加的学生数量: ");
|
|
|
|
|
if (scanf_s("%d", &numToInput) != 1) {
|
|
|
|
|
printf("无效输入,请输入一个整数。\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (*count + numToInput > MAX_STUDENTS) {
|
|
|
|
|
printf("无法添加更多学生,已达到最大容量。\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numToInput; i++) {
|
|
|
|
|
printf("Id: ");
|
|
|
|
|
scanf_s("%9s", students[*count].id, (unsigned)_countof(students[*count].id));
|
|
|
|
|
printf("Class: ");
|
|
|
|
|
scanf_s("%9s", students[*count].clas, (unsigned)_countof(students[*count].clas));
|
|
|
|
|
printf("Name: ");
|
|
|
|
|
scanf_s("%9s", students[*count].name, (unsigned)_countof(students[*count].name));
|
|
|
|
|
printf("Score1: ");
|
|
|
|
|
scanf_s("%lf", &students[*count].score1);
|
|
|
|
|
printf("Score2: ");
|
|
|
|
|
scanf_s("%lf", &students[*count].score2);
|
|
|
|
|
printf("Score3: ");
|
|
|
|
|
scanf_s("%lf", &students[*count].score3);
|
|
|
|
|
students[*count].score = students[*count].score1 + students[*count].score2 + students[*count].score3;
|
|
|
|
|
(*count)++;
|
|
|
|
|
start:
|
|
|
|
|
printf("continue?(yes/no)\n");
|
|
|
|
|
scanf_s("%9s", input, (unsigned)_countof(input));
|
|
|
|
|
if (strcmp(input, "yes") == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(input, "no") == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("无效输入,请输入yes或no。\n");
|
|
|
|
|
goto start;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void displayStudentInfo(Student students[], int count) {
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
printf("%s %s %s %.1lf %.1lf %.1lf %.1lf\n", students[i].id, students[i].clas, students[i].name,
|
|
|
|
|
students[i].score1, students[i].score2, students[i].score3, students[i].score);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|