#include <stdio.h>
#include <stdlib.h>
 
struct student{
        char name[21]; 
        int height, weight;
        };
 
int main(){
        int i, n, z, u, sum_height, sum_weight;
        double t = 10000.00;
        double s = 10000.00;
        double Height_avg, Weight_avg;
        sum_height = 0;
        sum_weight = 0;
 
    printf("請輸入人數: "); 
        scanf("%d", &n);
 
        struct student *a = (struct student *)malloc(sizeof(struct student)*n);
 
        for (i = 0; i < n; i++){
        scanf("請輸入姓名 身高 體重: %s %d %d", &a[i].name, &a[i].height, &a[i].weight);
        }
 
        for (i = 0; i < n; i++){
        sum_height += a[i].height;
        sum_weight += a[i].weight;
        }
 
        Height_avg = sum_height / n;
        Weight_avg = sum_weight / n;
 
        printf("Height_avg: %lf", Height_avg);
        printf("Weight_avg: %lf", Weight_avg);
 
        for (i = 0; i < n; i++){
                if(a[i].height < t){
                        t = a[i].height;
                    z = i;
                }
                if(a[i].weight < s){
                        s = a[i].weight;
                    u = i;
                }
        }
 
        if (a[i].height < Height_avg || a[i].weight < Weight_avg){
                printf("%s", a[z].name);
                printf("%s", a[u].name);
        }
 
        free(a);
        system("pause");
        return 0;
}
 