#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
struct DATA {
char name[16];
double cm;
double kg;
double bmi;
struct DATA* next;
};
struct DATA* head = NULL;
void add_data(struct DATA data)
{
struct DATA** pp;
struct DATA* p_new;
data.bmi = data.kg / (0.0001 * data.cm * data.cm);
p_new
= (struct DATA
*)malloc(sizeof data
); *p_new = data;
for (pp = &head; *pp; pp = &(*pp)->next) {
if (p_new->bmi < (*pp)->bmi) {
break;
}
}
p_new->next = *pp;
*pp = p_new;
}
void del_data(void)
{
struct DATA* p;
struct DATA* p_next;
for (p = head; p; p = p_next) {
p_next = p->next;
}
}
int main()
{
struct DATA data;
struct DATA* p;
while (1) {
scanf("%15s %lf %lf", data.
name, &data.
cm, &data.
kg); if (data.name[0] == '0') {
break;
}
add_data(data);
}
for (p = head; p; p = p->next) {
printf("BMI=%.2f 名前=%s 身長=%.1f 体重=%.1f\n", p->bmi, p->name, p->cm, p->kg);
}
del_data();
return 0;
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgoKc3RydWN0IERBVEEgewoJY2hhcgkJbmFtZVsxNl07Cglkb3VibGUJCWNtOwoJZG91YmxlCQlrZzsKCWRvdWJsZQkJYm1pOwoJc3RydWN0IERBVEEqCW5leHQ7Cn07CgpzdHJ1Y3QgREFUQSogaGVhZCA9IE5VTEw7Cgp2b2lkIGFkZF9kYXRhKHN0cnVjdCBEQVRBIGRhdGEpCnsKCXN0cnVjdCBEQVRBKioJcHA7CglzdHJ1Y3QgREFUQSoJcF9uZXc7CgoJZGF0YS5ibWkgPSBkYXRhLmtnIC8gKDAuMDAwMSAqIGRhdGEuY20gKiBkYXRhLmNtKTsKCXBfbmV3ID0gKHN0cnVjdCBEQVRBKiltYWxsb2Moc2l6ZW9mIGRhdGEpOwoJKnBfbmV3ID0gZGF0YTsKCWZvciAocHAgPSAmaGVh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