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