一种排序
来源:互联网 发布:软件测试周末班 编辑:程序博客网 时间:2024/06/07 09:00
此题涉及到:
strcut 结构体的排序问题 水题
题目链接:http://oj.nyist.me/OJ/contest_problem.php?cid=1033&pid=5
AC代码:
#include<bits/stdc++.h>using namespace std;struct aa{ int q,l,w;} a[10001];bool cmp(aa x,aa y){ if(x.q==y.q) { return x.l<y.l; if(x.l==y.l) return x.w<y.w; } return x.q<y.q;}int main(){ int n; scanf("%d",&n); while(n--) { int m; scanf("%d",&m); for(int i=0; i<m; i++) { scanf("%d%d%d",&a[i].q,&a[i].l,&a[i].w); if(a[i].l<a[i].w)//数值大的表示长,数值小的表示宽 { int j; j=a[i].l; a[i].l=a[i].w; a[i].w=j; } } sort(a,a+m,cmp);// printf("==\n"); for(int i=0;i<m;i++) { if(a[i+1].q==a[i].q&&a[i+1].l==a[i].l&&a[i+1].w==a[i].w)//编号 长宽相等输出一个 continue; else printf("%d %d %d\n",a[i].q,a[i].l,a[i].w); } }}
阅读全文
0 0
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 一种排序
- 写一段程序,比较浮点数和零的值得大小
- 关于winsock2 中boolean于oci中编译冲突问题
- SCOI2005 互不侵犯
- Java内存模型深度解读
- training deep learning model
- 一种排序
- Lintcode 115.不同的路径2
- spring ,structs2,hiberbate 整合 全注解版
- Deque-STL
- A road map to become a Data Scientist(上)
- 整合spring cloud云服务架构
- Lower Bound-STL
- calibrate kinnect v1 on ubuntu
- 定义一个宏,实现对数据a的第n位置位、清零、取反