#include <stdio.h>
typedef struct{
int id;
int weight;
int height;
}Body;
void swap(Body *b,Body *c){
Body work;
work = *b;
*b = *c;
*c = work;
}
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<4; i++){
for(int j=i+1; j<5; j++){
if(a[i].height<a[j].height){
swap(&a[i],&a[j]);
}
}
}
for(int k=0; k<5; k++){
printf("ID:%d,体重:%d,身長:%d\n",a
[k
].
id,a
[k
].
weight,a
[k
].
height); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdHsKCWludCBpZDsKCWludCB3ZWlnaHQ7CglpbnQgaGVpZ2h0Owp9Qm9keTsKCnZvaWQgc3dhcChCb2R5ICpiLEJvZHkgKmMpewoJQm9keSB3b3JrOwoJd29yayA9ICpiOwoJKmIgPSAqYzsKCSpjID0gd29yazsKfQoKaW50IG1haW4odm9pZCkgewoJQm9keSBhW109IHsJezEsNjUsMTY5fSwKCQkJCXsyLDczLDE3MH0sCgkJCQl7Myw1OSwxNjF9LAoJCQkJezQsNzksMTc1fSwKCQkJCXs1LDU1LDE2OH0gfTsKCQoJZm9yKGludCBpPTA7IGk8NDsgaSsrKXsKCQlmb3IoaW50IGo9aSsxOyBqPDU7IGorKyl7CgkJCWlmKGFbaV0uaGVpZ2h0PGFbal0uaGVpZ2h0KXsKCQkJCXN3YXAoJmFbaV0sJmFbal0pOwoJCQl9CgkJfQoJfQoJCglmb3IoaW50IGs9MDsgazw1OyBrKyspewoJCXByaW50ZigiSUQ6JWQs5L2T6YeNOiVkLOi6q+mVtzolZFxuIixhW2tdLmlkLGFba10ud2VpZ2h0LGFba10uaGVpZ2h0KTsKCX0KCQoJCglyZXR1cm4gMDsKfQo=
ID:4,体重:79,身長:175
ID:2,体重:73,身長:170
ID:1,体重:65,身長:169
ID:5,体重:55,身長:168
ID:3,体重:59,身長:161