parent
7ed7453a37
commit
3dd69e5506
@ -0,0 +1,76 @@
|
|||||||
|
#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 '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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue