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