#include <stdio.h>
typedef struct Personal
{
char name[50];
int ten;
} Kojin;
void show(Kojin *p);
void data_sort(Kojin *p);
int main(void)
{
Kojin data[5] = {{"A", 5},{"E",3},{"C",1},{"D",2},{"B",4}};
data_sort(data);
show(data);
return 0;
}
void show(Kojin *p)
{
int k;
for(k=0;k<5;k++)
printf("%s:%d \n",(p
+k
)->name
,(p
+k
)->ten
); }
void data_sort(Kojin *p)
{
int i,j,tmp;
for(i=0;i<5;i++){
for(j=4;j>i;j--){
if((p+j)->ten > (p+j-1)->ten){
tmp = (p+j)->ten;
(p+j)->ten = (p+j-1)->ten;
(p+j-1)->ten = tmp;
}
}
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCBQZXJzb25hbAp7CiAgICBjaGFyIG5hbWVbNTBdOwoJaW50IHRlbjsKfSBLb2ppbjsKCnZvaWQgc2hvdyhLb2ppbiAqcCk7CnZvaWQgZGF0YV9zb3J0KEtvamluICpwKTsKCmludCBtYWluKHZvaWQpCnsKCUtvamluIGRhdGFbNV0gPSB7eyJBIiwgNX0seyJFIiwzfSx7IkMiLDF9LHsiRCIsMn0seyJCIiw0fX07CglkYXRhX3NvcnQoZGF0YSk7CglzaG93KGRhdGEpOwoKCXJldHVybiAwOwp9Cgp2b2lkIHNob3coS29qaW4gKnApCnsKCWludCBrOwoKCWZvcihrPTA7azw1O2srKykKCQlwcmludGYoIiVzOiVkIFxuIiwocCtrKS0+bmFtZSwocCtrKS0+dGVuKTsKfQoKdm9pZCBkYXRhX3NvcnQoS29qaW4gKnApCnsKCWludCBpLGosdG1wOwoKCWZvcihpPTA7aTw1O2krKyl7CgkJZm9yKGo9NDtqPmk7ai0tKXsKCQkJaWYoKHAraiktPnRlbiA+IChwK2otMSktPnRlbil7CgkJCQl0bXAgPSAocCtqKS0+dGVuOwoJCQkJKHAraiktPnRlbiA9IChwK2otMSktPnRlbjsKCQkJCShwK2otMSktPnRlbiA9IHRtcDsKCQkJfQoJCX0KCX0KfQo=