#include // 定义学生结构体 struct Student { int id; float mathScore; float physicsScore; float englishScore; float totalScore; }; // 函数声明 void inputStudentInfo(struct Student* student); void displayStudentInfo(struct Student* student); int main() { // 定义三个学生 struct Student student1, student2, student3; // 输入学生信息 inputStudentInfo(&student1); inputStudentInfo(&student2); inputStudentInfo(&student3); // 显示学生信息 displayStudentInfo(&student1); displayStudentInfo(&student2); displayStudentInfo(&student3); return 0; } // 输入学生信息的函数 void inputStudentInfo(struct Student* student) { scanf("%d", &student->id); scanf("%f", &student->mathScore); scanf("%f", &student->physicsScore); scanf("%f", &student->englishScore); // 计算总成绩 student->totalScore = student->mathScore + student->physicsScore + student->englishScore; } // 显示学生信息的函数 void displayStudentInfo(struct Student* student) { printf("%d %.1f %.1f %.1f %.1f\n", student->id, student->mathScore, student->physicsScore, student->englishScore, student->totalScore); }