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