#include <stdio.h>
typedef struct stu
{
int num;
char name[10];
}stu_t;
int main()
{
stu_t student[5];
int i = 0;
int j = 0;
stu_t tmp;
for(i = 0; i < 5; i++)
{
printf("please enter NO.%d student's info:\n",i+1);
scanf("%d %s",&student[i].num,student[i].name);
}
//以下是排序部分
for(i = 0; i < 4; i++)
{
int k = i;
for(j = i+1; j < 5; j++)
if(student[k].num > student[j].num)
k = j;
tmp = student[i];
student[i] = student[k];
student[k] = tmp;
}
for(i = 0; i < 5; i++)
printf("student[%d].num = %d,name is :%s\n",i,student[i].num,student[i].name);
printf("Bye!\n");
return 0;
}