You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.0 KiB
77 lines
2.0 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
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 'i':
|
|
inputStudentsInfo();
|
|
break;
|
|
case 'o':
|
|
outputStudentsInfo();
|
|
break;
|
|
case 'm':
|
|
orderStudentsInfo();
|
|
break;
|
|
case 'q':
|
|
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;
|
|
}
|
|
}
|