#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;
}
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]);
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]);
}
}
}
printf("ID, Weight, Height\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+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBpbnQgaWQ7ICAgICAgCiAgICBpbnQgd2VpZ2h0OyAgCiAgICBpbnQgaGVpZ2h0OyAgCn0gQm9keTsKCnZvaWQgc3dhcChCb2R5ICphLCBCb2R5ICpiKSB7CiAgICBCb2R5IHRlbXAgPSAqYTsKICAgICphID0gKmI7CiAgICAqYiA9IHRlbXA7Cn0KCmludCBtYWluKCkgewogICAKICAgIEJvZHkgYVtdID0gewogICAgICAgIHsxLCA2NSwgMTY5fSwKICAgICAgICB7MiwgNzMsIDE3MH0sCiAgICAgICAgezMsIDU5LCAxNjF9LAogICAgICAgIHs0LCA3OSwgMTc1fSwKICAgICAgICB7NSwgNTUsIDE2OH0KICAgIH07CgogICAgaW50IG4gPSBzaXplb2YoYSkgLyBzaXplb2YoYVswXSk7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBuIC0gaSAtIDE7IGorKykgewogICAgICAgICAgICBpZiAoYVtqXS5oZWlnaHQgPCBhW2ogKyAxXS5oZWlnaHQpIHsKICAgICAgICAgICAgICAgIHN3YXAoJmFbal0sICZhW2ogKyAxXSk7IAogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIHByaW50ZigiSUQsIFdlaWdodCwgSGVpZ2h0XG4iKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCIlZCwgJWQsICVkXG4iLCBhW2ldLmlkLCBhW2ldLndlaWdodCwgYVtpXS5oZWlnaHQpOwogICAgfQoKICAgIHJldHVybiAwOwp9
ID, Weight, Height
4, 79, 175
2, 73, 170
1, 65, 169
5, 55, 168
3, 59, 161