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.

91 lines
2.3 KiB

#include <stdio.h>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
typedef struct {
int student_id;
float math_grade;
float physics_grade;
float english_grade;
float total_grade;
} Student;
//¼<><C2BC>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
void inputInfo() {
printf("Please input info of the three students:\n");
Student students[3];
for (int i = 0; i < 3; i++) {
//<2F><>ʵ<EFBFBD><CAB5>printfע<66><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʲô<CAB2><C3B4><EFBFBD><EFBFBD>
//printf("ID");
scanf("%d", &students[i].student_id);
//printf("math grade");
scanf("%f", &students[i].math_grade);
//printf("physics grade");
scanf("%f", &students[i].physics_grade);
//printf("english grade");
scanf("%f", &students[i].english_grade);
students[i].total_grade = students[i].math_grade + students[i].physics_grade + students[i].english_grade;
}
// <20><><EFBFBD><EFBFBD>
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2 - i; j++) {
if (students[j].total_grade > students[j + 1].total_grade) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
//<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ӣ<><D3A2> <20>ܳɼ<DCB3>
for (int i = 0; i < 3; i++) {
printf("%d %.1f %.1f %.1f %.1f\n", students[i].student_id, students[i].math_grade,students[i].physics_grade,students[i].english_grade,students[i].total_grade);
}
}
void outputInfo() {
printf("You are trying to Output info.\n");
}
void makeOrdered() {
printf("You are trying to Make things ordered.\n");
}
//<2F>˵<EFBFBD>
int main() {
char choice;
printf("Main Menu:\n");
printf("%30s 1.Input\n", "");
printf("%30s 2.Output\n", "");
printf("%30s 3.Order\n", "");
printf("%30s 4.Quit\n", "");
printf("Please enter your choice: ");
scanf(" %c", &choice);
//ѡ<><D1A1>
switch (choice) {
case 'i':
inputInfo();
break;
case 'o':
outputInfo();
break;
case 'm':
makeOrdered();
break;
case 'q':
printf("You are about to Quit.\n");
break;
default:
printf("Wrong input.\n");
break;
}
return 0;
}