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