#include <stdio.h>
typedef struct{
int id;
int weight;
int height;
}Body;
void swap(Body *a, Body *b) {
Body w=*a;
*a=*b;
*b=w;
}
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 <5-1; i++) {
for (int j=0;j<5-i-1;j++) {
if (a[j].height<a[j+1].height) {
swap(&a[j],&a[j+1]);
}
}
}
for(int i=0;i<5;i++){
printf("id:%d weight:%d height:%d\n", a
[i
].
id,a
[i
].
weight,a
[i
].
height); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CnR5cGVkZWYgc3RydWN0ewoJaW50IGlkOwoJaW50IHdlaWdodDsKCWludCBoZWlnaHQ7Cn1Cb2R5OwoKdm9pZCBzd2FwKEJvZHkgKmEsIEJvZHkgKmIpIHsKICAgIEJvZHkgdz0qYTsKICAgICphPSpiOwogICAgKmI9dzsKfQoKaW50IG1haW4odm9pZCkgewogICAgQm9keSBhW109e3sxLDY1LDE2OX0sezIsNzMsMTcwfSx7Myw1OSwxNjF9LHs0LDc5LDE3NX0sezUsNTUsMTY4fX07CiAgICAgZm9yIChpbnQgaT0wOyBpIDw1LTE7IGkrKykgewogICAgICAgIGZvciAoaW50IGo9MDtqPDUtaS0xO2orKykgewogICAgICAgICAgICBpZiAoYVtqXS5oZWlnaHQ8YVtqKzFdLmhlaWdodCkgewogICAgICAgICAgICAgICAgc3dhcCgmYVtqXSwmYVtqKzFdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICB9CiAgICBmb3IoaW50IGk9MDtpPDU7aSsrKXsKICAgIHByaW50ZigiaWQ6JWQgd2VpZ2h0OiVkIGhlaWdodDolZFxuIiwgYVtpXS5pZCxhW2ldLndlaWdodCxhW2ldLmhlaWdodCk7Cn0KcmV0dXJuIDA7Cn0=