#include <stdio.h>
#define NUMBER 5
typedef struct{
int id;
int weight;
int height;
}Body;
void swap(Body *x,Body *y);
int main(void) {
Body data[]={{1,65,169},
{2,73,170},
{3,59,161},
{4,79,175},
{5,55,168},
};
for(int i=0;i<5;i++){
for(int j=0;j<4;j++){
if(data[j].height<=data[j+1].height){
swap(&data[j],&data[j+1]);
}
}
}
for(int i=0; i<NUMBER;i++){
printf("id : %d, weight : %d, height : %d\n",data
[i
].
id,data
[i
].
weight,data
[i
].
height); }
return 0;
}
void swap(Body *x,Body *y){
Body w = *x;
*x = *y;
*y = w;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgTlVNQkVSIDUKCnR5cGVkZWYgc3RydWN0ewoJaW50IGlkOwoJaW50IHdlaWdodDsKCWludCBoZWlnaHQ7Cn1Cb2R5OwoKdm9pZCBzd2FwKEJvZHkgKngsQm9keSAqeSk7CgppbnQgbWFpbih2b2lkKSB7CglCb2R5IGRhdGFbXT17ezEsNjUsMTY5fSwKCQkJCSB7Miw3MywxNzB9LAoJCQkJIHszLDU5LDE2MX0sCgkJCQkgezQsNzksMTc1fSwKCQkJCSB7NSw1NSwxNjh9LAoJfTsKCQoJZm9yKGludCBpPTA7aTw1O2krKyl7CgkJZm9yKGludCBqPTA7ajw0O2orKyl7CgkJaWYoZGF0YVtqXS5oZWlnaHQ8PWRhdGFbaisxXS5oZWlnaHQpewoJCQlzd2FwKCZkYXRhW2pdLCZkYXRhW2orMV0pOwoJCX0KCX0KCX0KCQoJZm9yKGludCBpPTA7IGk8TlVNQkVSO2krKyl7CgkJcHJpbnRmKCJpZCA6ICVkLCB3ZWlnaHQgOiAlZCwgaGVpZ2h0IDogJWRcbiIsZGF0YVtpXS5pZCxkYXRhW2ldLndlaWdodCxkYXRhW2ldLmhlaWdodCk7Cgl9CglyZXR1cm4gMDsKfQoKCnZvaWQgc3dhcChCb2R5ICp4LEJvZHkgKnkpewogCgkgQm9keSB3ID0gKng7CgkqeCA9ICp5OwoJKnkgPSB3Owp9
id : 4, weight : 79, height : 175
id : 2, weight : 73, height : 170
id : 1, weight : 65, height : 169
id : 5, weight : 55, height : 168
id : 3, weight : 59, height : 161