我的代码
#include<stdio.h>
struct student
{
int num[5];
char name[10];
int score;
}stu[5];
int main()
{
int i, j, k, l;
//printf("input the number of the student\n");
//scanf_s("%d\n",&n);
printf("input the students's num,name,score\n");
for (l = 0; l < 5; l++)
{
printf("input the students's num:");
scanf_s("%5d", stu[l].num);
printf("input the students's name:");
scanf_s("%s", stu[l].name);
printf("input the students's score:");
scanf_s("%5d", stu[l].score);
printf("\n");
}
struct student temp;
for (i = 0; i <= 5; i++)
{
k = i;
for (j = 0; j <= 5; j++)
if (stu[j].score>stu[k].score)
k = j;
temp = stu[k]; stu[k] = stu[j]; stu[j] = temp;
}
for (i = 0; i < 5; i++)
printf("%6d,%10s,%5f\n", stu[i].num, stu[i].name, stu[i].score);
printf("\n");
return 0;
}