POJ 1547 Clay Bully 结构体数组使用题意理解
2010-11-27 20:47
357 查看
这题很简单,可以设置结构体保存三维及姓名,求出体积最大的人和最小的人输出即可。
由于没有注意输出"."而贡献了一次WA,囧
由于没有注意输出"."而贡献了一次WA,囧
#include <iostream> #include <algorithm> #include <string> using namespace std; struct stu{ stu(){} string name; int d; }s[1000]; int comp(const void * a,const void * b){ return ((stu*)a)->d - ((stu*)b)->d; } int main(){ int n,i,a,b,c,dd; while(1){ cin>>n; if (n == -1) break; for (i = 0 ;i < n;i++) { cin>>a>>b>>c; dd = a*b*c; s[i].d = dd; cin>>s[i].name; } qsort(s,n,sizeof(s[0]),comp); cout<<s[--n].name<<" took clay from "<<s[0].name<<"."<<endl; } return 0; }
相关文章推荐
- POJ 1547 Clay Bully 结构体数组使用题意理解
- 数组定义和使用,理解多维数组和Array类
- (使用STL自带的排序功能进行排序7.3.2)POJ 2092 Grandpa is Famous(结构体排序)
- poj 2752 ( fail 数组的理解 )
- 对使用倒序的一维数组解决0/1背包问题的理解
- 使用结构体实现连续存储数组增删改查等各种操作
- iOS 中由数组 NSArray 与 NSMutableArray 的使用理解偏差引发的多宗血案
- POj - 2752 Seek the Name, Seek the Fame 【next数组的理解】
- 【C语言】使用结构体数组
- POJ 2470 Ambiguous permutations(简单题 理解题意)
- poj 1961 2406 让你彻底理解KMP的next[]数组的两个题目
- ZOJ 1755 && POJ 1547 Clay Bully(简单排序+map容器)
- main函数参数的使用和指针数组的理解结合实例
- 使用容器的概念理解多维数组和多维空间
- php的array数组和使用实例简明教程(容易理解)
- poj 2752 KMPnext[]数组的理解 以及 两种优化
- POJ 1547:Clay Bully
- c++与C# winform的消息通讯--(结构体与byte数组的使用)
- POJ3664---没使用结构体,用数组(未AC)
- C语言-指针、数组、结构体、分支、循环混合使用