#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Student {
char name[20];
int age;
char sex;
int score;
};
void set_init( struct Student *stu_p)
{
int i;
for (i = 0; i < LEN; i++) {
scanf("%s %d %c %d", stu_p[i].name,
&stu_p[i].age,
&stu_p[i].sex,
&stu_p[i].score);
}
}
void sort(struct Student *stu_p) {
int i, j, flag;
struct Student temp;
for (i = 0; i < LEN-1; i++) {
for (flag = 0, j = 0; j < LEN - i - 1; j++) {
if (stu_p[j].score > stu_p[j+1].score) {
temp = stu_p[j];
stu_p[j] = stu_p[j+1];
stu_p[j+1] = temp;
flag = 1;
}
}
if ( flag == 0) {
break;
}
}
}
void show( struct Student *stu_p)
{
int i;
for (i = 0; i < LEN; i++) {
printf("姓名:%s\t年龄:%d\t性别:%c\t成绩:%d\n", stu_p[i].name,
stu_p[i].age,
stu_p[i].sex,
stu_p[i].score);
}
}
int main(int argc, const char *argv[])
{
struct Student stu_arr[LEN] = {0};
set_init( stu_arr);
sort(stu_arr);
show(stu_arr);
return 0;
}