回复 3楼 x无名氏x
程序代码:
#include<stdio.h>
struct student
{
char name[20];
char id[20];
float score;
}stu[100];
int main()
{
int n = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%s%s%f", stu[i].name, stu[i].id, &stu[i].score);
}
for (int i = 0; i < n-1; i++) //选择排序
{
for (int j = i+1; j < n; j++)
{
if (stu[i].score >= stu[j].score)
{
struct student s;
s = stu[i];
stu[i] = stu[j];
stu[j] = s;
}
}
}
printf("%s %s\n", stu[0].name, stu[0].id);
printf("%s %s", stu[n - 1].name, stu[n - 1].id);
return 0;
}