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