From 3dd69e5506d7cba2b383974db2cba6ce86f787ad Mon Sep 17 00:00:00 2001 From: m7wzyfpis <1040766652@qq.com> Date: Mon, 13 Nov 2023 14:59:40 +0800 Subject: [PATCH] ADD file via upload --- 3.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 3.c diff --git a/3.c b/3.c new file mode 100644 index 0000000..6a84b16 --- /dev/null +++ b/3.c @@ -0,0 +1,76 @@ +#include +#include + +void inputStudentsInfo(); +void outputStudentsInfo(); +void orderStudentsInfo(); + +int main() { + char input; + + while (1) { + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + printf("Please enter your choice: "); + scanf(" %c", &input); + + switch (input) { + case '1': + inputStudentsInfo(); + break; + case '2': + outputStudentsInfo(); + break; + case '3': + orderStudentsInfo(); + break; + case '4': + printf("You are about to Quit\n"); + exit(0); + default: + printf("Wrong input\n"); + break; + } + } + + return 0; +} + +void inputStudentsInfo() { + int studentID[3]; + float mathScore[3], physicsScore[3], englishScore[3], totalScore[3]; + + printf("Please input info of the three students:\n"); + for (int i = 0; i < 3; i++) { + printf("Student %d: ", i+1); + scanf("%d%f%f%f", &studentID[i], &mathScore[i], &physicsScore[i], &englishScore[i]); + totalScore[i] = mathScore[i] + physicsScore[i] + englishScore[i]; + } + + printf("\nSorted students info:\n"); + for (int i = 0; i < 3; i++) { + printf("学号%d,总成绩%.1f,平均成绩%.1f\n", studentID[i], totalScore[i], totalScore[i] / 3); + } +} + +void outputStudentsInfo() { + printf("You are trying to Make things ordered\n"); +} + +void orderStudentsInfo() { + printf("Please enter your choice: "); + char input; + scanf(" %c", &input); + + switch(input) { + case 'q': + case 'Q': + printf("You are about to Quit\n"); + exit(0); + default: + printf("Wrong input\n"); + break; + } +}