#include<stdio.h>
typedef struct student
{
char *name;
int sno;
int age;
float score;
}Student;
void sortScore(Student st[],int len)
{
int flag = 0;
for(int i=0;i<len-1;i++)
{
flag = 1;
for(int j=0;j<len-1-i;j++)
{
if(st[j].score>st[j+1].score)
{
Student temp = st[j];
st[j] = st[j+1];
st[j+1] = temp;
}
}
if(flag==0)
{
break;
}
}
}
void printStudent(Student stu[],int len)
{
for(int i=0;i<len;i++)
{
printf("name:%s,sno:%d,age:%d,score:%.1f\n",stu[i].name,stu[i].sno,
stu[i].age,stu[i].score);
}
}
int main()
{
Student stu[3] = {{"Tom",1101,18,99.2},
{"Boy",1102,20,98.1},
{"Smith",1103,22,99.0}};
sortScore(stu,3);
printStudent(stu,3);
return 0;
}