|
发表于 2014-8-9 18:56:29
|
显示全部楼层
- #include <stdio.h>
- #include <algorithm>
- using namespace std;
- struct stduent
- {
- int size; // 如果没有谁抢谁的,那么他们橡皮的体积应该一样
- char name[10];
- bool operator < (const stduent &B) const
- {
- return size < B.size;
- } // 这个函数是为了调用 sort 对结构体排序,不理解先背下来好了,我也是这样做的
- }student[12];
- int main()
- {
- int n;
- while(~scanf("%d",&n),n != -1) // ~ 当输入文件结尾退出
- {
- int i,x,y,h,s;
- for(i=0;i<n;i++)
- {
- scanf("%d%d%d",&x,&y,&h);
- student[i].size=x*y*h;
- getchar(); // 吃到输完数字后那个空格或者回车
- scanf("%s",student[i].name);
- }
- sort(student,student+n);
- printf("%s took clay from %s\n",student[n-1].name,student[0].name);
- }
- return 0;
- }
复制代码
囧。。。没注意到这样贴代码好一点 |
|