网站建设可自学吗,网站建设设计指标,高校二级学院网站建设管理制度,外贸建站用什么平台好幼儿园的老师给几位小朋友等量的长方体橡皮泥#xff0c;但有个小朋友#xff08;小霸王#xff09;觉得自己的橡皮泥少了#xff0c;就从另一个小朋友那里抢了一些。请问#xff0c;是哪个小霸王抢了哪个小朋友的橡皮泥#xff1f;
输入格式:
测试数据有多组。对于每组…幼儿园的老师给几位小朋友等量的长方体橡皮泥但有个小朋友小霸王觉得自己的橡皮泥少了就从另一个小朋友那里抢了一些。请问是哪个小霸王抢了哪个小朋友的橡皮泥
输入格式:
测试数据有多组。对于每组测试首先输入一个整数nn≤500然后输入n行每行包括3个不超过1000的整数l、w、h和1个字符串name不超过8个字符且不含空格其中l、w、h分别表示橡皮泥的长、宽、高name表示小朋友的姓名。当n等于-1时输入结束。
输出格式:
对于每组测试按“name1 took clay from name2.”的格式输出一行其中name1代表小霸王的名字name2代表被抢小朋友的名字具体参考输出样例。
输入样例:
3
10 10 2 Jill
5 3 10 Will
5 5 10 Bill
-1输出样例:
Bill took clay from Will.
#includestdio.h
struct my_struct
{int l;int w;int h;char name[100];
};
int cmpnum(const void* p1, const void* p2)
{return (((struct my_struct*)p1)-l * ((struct my_struct*)p1)-w * ((struct my_struct*)p1)-h) - ((struct my_struct*)p2)-l * ((struct my_struct*)p2)-w * ((struct my_struct*)p2)-h;
}
int main()
{int n 0;while (1){scanf(%d, n);if (n-1){break;}struct my_struct arr[100];for (int i 0; i n; i){scanf(%d %d %d %s, arr[i].l, arr[i].w, arr[i].h, arr[i].name);}qsort(arr, n, sizeof(arr[0]), cmpnum);printf(%s took clay from %s.\n, arr[n - 1].name, arr[0].name);}}