#include <stdio.h>
#include <stdlib.h>
struct student {
char name[20];
double height;
double weight;
double bmi;
};
int main()
{
char s[100],buf[100];
int c=0,i,j;
FILE *fp;
struct student *data,t;
double h;
/* printf("file name = ");*/
if(!fp) {
return 1;
}
while(fgets(buf
,100,fp
))c
++;
data
=malloc(c
*sizeof(struct student
)); for(i
=0; fgets(buf
,100,fp
); i
++) { sscanf(buf
,"%s %lf %lf",data
[i
].
name,&data
[i
].
height,&data
[i
].
weight); h=data[i].height/100;
data[i].bmi=data[i].weight/h/h;
}
for(i=0; i<c; i++) {
for(j=i+1; j<c; j++) {
if(data[i].bmi<data[j].bmi) {
t=data[i];
data[i]=data[j];
data[j]=t;
}
}
}
for(i=0; i<c; i++) {
printf("%s BMI=%f",data
[i
].
name,data
[i
].
bmi); if(data
[i
].
bmi>25)printf(" himan"); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnN0cnVjdCBzdHVkZW50IHsKICBjaGFyIG5hbWVbMjBdOwogIGRvdWJsZSBoZWlnaHQ7CiAgZG91YmxlIHdlaWdodDsKICBkb3VibGUgYm1pOwp9OwoKaW50IG1haW4oKQp7CiAgY2hhciBzWzEwMF0sYnVmWzEwMF07CiAgaW50IGM9MCxpLGo7CiAgRklMRSAqZnA7CiAgc3RydWN0IHN0dWRlbnQgKmRhdGEsdDsKICBkb3VibGUgaDsKCi8qICBwcmludGYoImZpbGUgbmFtZSA9ICIpOyovCiAgc2NhbmYoIiVzIixzKTsKICBmcD1mb3BlbihzLCJyIik7CiAgaWYoIWZwKSB7CiAgICBwcmludGYoImZpbGUgb3BlbiBlcnJvciFcbiIpOwogICAgcmV0dXJuIDE7CiAgfQoKICB3aGlsZShmZ2V0cyhidWYsMTAwLGZwKSljKys7CiAgcmV3aW5kKGZwKTsKCiAgZGF0YT1tYWxsb2MoYypzaXplb2Yoc3RydWN0IHN0dWRlbnQpKTsKICBmb3IoaT0wOyBmZ2V0cyhidWYs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