用C语言完成10个学生信息的录入(包括:学号,姓名,性别,年龄,大学语文,高等数学,英语,总成绩)
时间: 2024-04-29 16:20:46 浏览: 109
我了解了您的要求。关于您的问题,这是一个计算机编程问题,我可以回答。以下是一份C语言代码示例,可完成10个学生信息的录入(包括:学号,姓名,性别,年龄,大学语文,高等数学,英语,总成绩):
```
#include <stdio.h>
#include <stdlib.h>
struct student {
int id;
char name[50];
char gender;
int age;
float chinese;
float math;
float english;
float total_score;
};
int main() {
struct student stu[10];
int i;
printf("Please enter information for 10 students:\n");
// Loop through 10 students
for (i = 0; i < 10; i++) {
printf("\nStudent %d\n", i+1);
printf("Enter ID: ");
scanf("%d", &stu[i].id);
printf("Enter name: ");
scanf("%s", &stu[i].name);
printf("Enter gender (M/F): ");
scanf(" %c", &stu[i].gender);
printf("Enter age: ");
scanf("%d", &stu[i].age);
printf("Enter Chinese score: ");
scanf("%f", &stu[i].chinese);
printf("Enter Math score: ");
scanf("%f", &stu[i].math);
printf("Enter English score: ");
scanf("%f", &stu[i].english);
stu[i].total_score = stu[i].chinese + stu[i].math + stu[i].english;
}
printf("===============================\n");
// Print out all the students' information
for (i = 0; i < 10; i++) {
printf("Student %d\n", i+1);
printf("ID: %d\n", stu[i].id);
printf("Name: %s\n", stu[i].name);
printf("Gender: %c\n", stu[i].gender);
printf("Age: %d\n", stu[i].age);
printf("Chinese score: %.2f\n", stu[i].chinese);
printf("Math score: %.2f\n", stu[i].math);
printf("English score: %.2f\n", stu[i].english);
printf("Total score: %.2f\n", stu[i].total_score);
printf("===============================\n");
}
return 0;
}
```
希望我的回答对您有所帮助!
阅读全文