Delete 'order_other_opinion.c'

main
pr9nfksyw 1 week ago
parent f063e83d93
commit d97c47e36a

@ -1,131 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include<time.h>
#include "menu.h"
void insertStudentInfo(Student students[], int* count) {
if (*count >= MAX_STUDENTS) {
printf("学生已满,无法添加新学生。\n");
return;
}
Student newStudent;
int validInput;
do {
validInput = 1;
printf("Id: ");
scanf_s("%9s", newStudent.id, (unsigned)_countof(newStudent.id));
// 验证学号是否只由数字组成
for (int i = 0; i < strlen(newStudent.id); i++) {
if (!isdigit(newStudent.id[i])) {
validInput = 0;
break;
}
}
if (!validInput) {
printf("学号只能由数字组成,请重新输入。\n");
}
} while (!validInput);
printf("Class: ");
scanf_s("%9s", newStudent.clas, (unsigned)_countof(newStudent.clas));
printf("Name: ");
scanf_s("%9s", newStudent.name, (unsigned)_countof(newStudent.name));
printf("Score1: ");
scanf_s("%lf", &newStudent.score1);
printf("Score2: ");
scanf_s("%lf", &newStudent.score2);
printf("Score3: ");
scanf_s("%lf", &newStudent.score3);
newStudent.score = newStudent.score1 + newStudent.score2 + newStudent.score3;
int i = *count;
while (i > 0 && (strcmp(students[i - 1].clas, newStudent.clas) > 0 ||
(strcmp(students[i - 1].clas, newStudent.clas) == 0 && students[i - 1].score < newStudent.score))) {
students[i] = students[i - 1];
i--;
}
students[i] = newStudent;
(*count)++;
}
void deleteStudentInfo(Student students[], int* count) {
char input[20];
printf("Enter the student ID or name to delete: ");
scanf_s("%19s", input, (unsigned)_countof(input));
int i = 0;
while (i < *count && (strcmp(students[i].id, input) != 0 && strcmp(students[i].name, input) != 0)) {
i++;
}
if (i == *count) {
printf("Student not found.\n");
}
else {
for (int j = i; j < *count - 1; j++) {
students[j] = students[j + 1];
}
(*count)--;
printf("Student deleted successfully.\n");
}
}
void modifyStudentInfo(Student students[], int count) {
char input[20];
printf("Enter the student ID to modify: ");
scanf_s("%19s", input, (unsigned)_countof(input));
int i = 0;
while (i < count && strcmp(students[i].id, input) != 0) {
i++;
}
if (i == count) {
printf("Student not found.\n");
}
else {
printf("Id: ");
scanf_s("%9s", students[i].id, (unsigned)_countof(students[i].id));
printf("Class: ");
scanf_s("%9s", students[i].clas, (unsigned)_countof(students[i].clas));
printf("Name: ");
scanf_s("%9s", students[i].name, (unsigned)_countof(students[i].name));
printf("Score1: ");
scanf_s("%lf", &students[i].score1);
printf("Score2: ");
scanf_s("%lf", &students[i].score2);
printf("Score3: ");
scanf_s("%lf", &students[i].score3);
students[i].score = students[i].score1 + students[i].score2 + students[i].score3; // Fixed here
printf("Student information updated successfully.\n");
}
}
void queryStudentInfo(Student students[], int count) {
char queryClass[MAX_STRING];
printf("请输入要查询的班级: ");
scanf_s("%9s", queryClass, (unsigned)_countof(queryClass));
printf("查询结果:\n");
for (int i = 0; i < count; i++) {
if (strcmp(students[i].clas, queryClass) == 0) {
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);
}
}
}
Loading…
Cancel
Save