vector去重 nyoj 8 一种排序
来源:互联网 发布:知乎每日精选 编辑:程序博客网 时间:2024/05/01 09:11
//去重 vector<cuboid>::iterator end_unique=unique(a.begin(),a.end()); //删除重复 a.erase(end_unique,a.end());
本文来自http://hi.baidu.com/luckyboy 博主的代码
#include <iostream>#include <vector>#include <algorithm>using namespace std;struct cuboid{ int cid; int length; int width;} box;void print(cuboid s){ cout<<s.cid<<" "<<s.length<<" "<<s.width<<endl;}bool operator < (const cuboid& lhs,const cuboid& rhs){ if(lhs.cid>rhs.cid) { return false;//lhs.cid>rhs.cid; } else if(lhs.cid==rhs.cid&&lhs.length>rhs.length) { return false;//return lhs.length>rhs.length; } else if(lhs.cid==rhs.cid&&lhs.length==rhs.length&&lhs.width>rhs.width) { return false;//return lhs.width>rhs.width; } return true;}bool operator ==( const cuboid& lhs,const cuboid rhs ){ if(lhs.cid==rhs.cid&&lhs.length==rhs.length&&lhs.width==rhs.width) { return true; } else return false;}int main(){ vector<cuboid> a; int num1,num2; cin>>num1; for(int i=num1; i>0; i--) { cin>>num2; for(int j=num2; j>0; j--) { cin>>box.cid; cin>>box.length; cin>>box.width; if(box.length<box.width) { int t=box.length; box.length=box.width; box.width=t; } a.push_back(box); } sort(a.begin(),a.end()); //去重 vector<cuboid>::iterator end_unique=unique(a.begin(),a.end()); //删除重复 a.erase(end_unique,a.end()); for_each(a.begin(),a.end(),print); a.clear(); } return 0;}
- vector去重 nyoj 8 一种排序
- NYOJ 8 一种排序 快排 去重
- NYOJ 8 一种排序
- NYOJ 8 一种排序
- NYOJ 8 一种排序
- NYOJ 8-一种排序
- NYOJ,8,一种排序
- NYOJ--8--一种排序
- nyoj-8-一种排序
- nyoj 8 一种排序
- 一种排序NYOJ 8
- NYOJ 8 一种排序
- NYOJ 8 一种排序
- 一种排序(nyoj 8)
- NYOJ 8 一种排序
- NYOJ 8 一种排序
- nyoj 8 一种排序
- nyoj 8 一种排序
- ADO 教程 (VC++)
- 日常NSDate使用整理
- Porting LTP to Android
- C++ - 网络编程模型 - Linux EPOLL .
- Sequel中文文档-模型-关联基础
- vector去重 nyoj 8 一种排序
- 我的手机编年史
- Cocos-2d 关于SwallowTouch,进一步解释触摸事件分发机制
- 高性能IO设计的Reactor和Proactor模式 .
- windows和linux系统下数据传输工具——tftpd32使用说明
- oracle 将一列数据转成1行数据
- R语言基础入门(全)
- clientHeight,clientWidth,scrollWidth,scrollHeight,offsetWidth,offsetHeight的说明
- vc之字符类型区别