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.

47 lines
1.2 KiB

#include <stdio.h>
// <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><E1B9B9>
struct Student {
int id;
float mathScore;
float physicsScore;
float englishScore;
float totalScore;
};
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void inputStudentInfo(struct Student* student);
void displayStudentInfo(struct Student* student);
int main() {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
struct Student student1, student2, student3;
// <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ
inputStudentInfo(&student1);
inputStudentInfo(&student2);
inputStudentInfo(&student3);
// <20><>ʾѧ<CABE><D1A7><EFBFBD><EFBFBD>Ϣ
displayStudentInfo(&student1);
displayStudentInfo(&student2);
displayStudentInfo(&student3);
return 0;
}
// <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
void inputStudentInfo(struct Student* student) {
scanf("%d", &student->id);
scanf("%f", &student->mathScore);
scanf("%f", &student->physicsScore);
scanf("%f", &student->englishScore);
// <20><><EFBFBD><EFBFBD><EFBFBD>ܳɼ<DCB3>
student->totalScore = student->mathScore + student->physicsScore + student->englishScore;
}
// <20><>ʾѧ<CABE><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
void displayStudentInfo(struct Student* student) {
printf("%d %.1f %.1f %.1f %.1f\n", student->id, student->mathScore, student->physicsScore, student->englishScore, student->totalScore);
}