NYOJ8一种排序
来源:互联网 发布:19级研究所升级数据 编辑:程序博客网 时间:2024/04/30 16:09
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=8
STL sort的模板题,注意一下输入的时候长和宽的问题。。
代码:
#include <cstdio>#include <algorithm>using namespace std;struct Node{ int number; int length; int width;}a[1005];bool cmp(Node x,Node y){ if(x.number != y.number) return x.number < y.number; else if(x.length != y.length) return x.length < y.length; else if(x.width != y.width) return x.width < y.width;}bool isEquals(Node x,Node y){ if(x.number == y.number && x.length == y.length && x.width == y.width) return true; return false;}int main(){ int _case; scanf("%d",&_case); while(_case--) { int m; scanf("%d",&m); for(int i = 0;i < m;++i){ scanf("%d%d%d",&a[i].number,&a[i].length,&a[i].width); if(a[i].length < a[i].width) { int t = a[i].length; a[i].length = a[i].width; a[i].width = t; } } sort(a,a + m,cmp); printf("%d %d %d\n",a[0].number,a[0].length,a[0].width); for(int i = 1;i < m;++i) if(!isEquals(a[i],a[i - 1])) printf("%d %d %d\n",a[i].number,a[i].length,a[i].width); } return 0;}
0 0
- nyoj8一种排序
- nyoj8 一种排序
- NYOJ8一种排序
- NYOJ8一种排序
- nyoj8 一种排序(排序变形)
- 一种排序(nyoj8)(简单排序)
- nyoj8 一种排序(sort三级排序)
- nyoj8 一种排序(用set)
- nyoj8(一种排序)(结构体的二级排序)
- nyoj8
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 37.Swing小综合-计算器
- Android自定义View之Layout的放缩(1)
- c++实验3--个人所得税计算器
- java中处理Json
- PCL Step by Step:(1)PCL1.8+VS2015+win10编译
- NYOJ8一种排序
- 最大岛屿
- [LeetCode]4. Median of Two Sorted Arrays
- C#之数据序列化
- 【福利贴】教你如何移动联通电信免流
- Dom4j解析xml使用方法
- 光标问题
- 电脑装系统之UltraIso(软碟通)
- Struts2学习