#include<stdio.h>
struct student
{
int num;
char name[20];
int sub1;
int sub2;
int sub3;
float aver;
};
float ave(int a, int b, int c)
{
float d;
d = (a + b + c) / 3.0;
return d;
}
int main()
{
struct student people[10];
int i, j = 0;
printf("请依次按照顺序输入各学生的学号,姓名,sub1,sub2,sub3;\n");
for (i = 0; i < 10; i++)
{
scanf_s("%d,%s,%d,%d,%d", &people[i].num, people[i].name, &people[i].sub1, &people[i].sub2, &people[i].sub3);
}
for (i = 0; i < 10; i++)
{
people[i].aver = ave(people[i].sub1, people[i].sub2, people[i].sub3);
}
for (i = 0; i < 10; i++)
{
if (people[i].aver > people[j].aver)
j = i;
}
for (i = 0; i < 10; i++)
{
printf("%s同学的成绩是%f\n", people[i].name, people[i].aver);
}
printf("最高分的人的学号是%d\n姓名是%s\nsub1是%d\nsub2是%d\nsub3是%d\n平均分是%f\n", people[j].num, people[j].name, people[j].sub1, people[j].sub2, people[j].sub3, people[j].aver);
return 0;
}
大佬们救救我啊,我哪里错了
最新推荐文章于 2024-08-14 11:57:07 发布