#include<iostream>
#include<set>
using namespace std;
struct P
{
int entry;
int time;
bool operator<(const P &b)const {
return (this->entry<b.entry);
} };
int main()
{
while(!cin.eof())
{
int n;
cin>>n;
set<P> s;
P tmp; for(int i = 0;i<n;i++)
{
tmp.time = 1;
cin>>tmp.entry;
if(s.find(tmp)==s.end())s.insert(tmp);
else
{
set<P>::iterator it; it = s.find(tmp);
tmp=*it;
tmp.time++;
s.erase(it);
s.insert(tmp);
}
}
set<P>::iterator itr;
for(itr = s.begin();itr!=s.end()&&!cin.eof();itr++)
if(itr->time % 2)
cout<<itr->entry<<endl;
}
}
举例:

#include <map>
#include <iostream>
#include <string> using namespace std; //学生信息
typedef struct tagStudentInfo
{
int nID;
string strName;
bool operator <(const tagStudentInfo &A) const
{
if (nID < A.nID) return true; //先比较nID
if (nID == A.nID) return strName.compare(A.strName) < ; //nID相同时,再比较strName
return false;
} }StudentInfo,*pstudentInfo;

结构体用于map,set时要重载运算符<的更多相关文章

  1. 结构体作为map的key或放入set中,需要重载<运算符

    结构体作为map的key或放入set中,需要重载<运算符,如下: typedef struct tagRoadKey{    int m_i32Type;    int m_i32Scale; ...

  2. GO学习-(38) Go语言结构体转map[string]interface{}的若干方法

    结构体转map[string]interface{}的若干方法 本文介绍了Go语言中将结构体转成map[string]interface{}时你需要了解的"坑",也有你需要知道的若 ...

  3. Golang操作结构体、Map转化为JSON

    结构体生成Json package main import ( "encoding/json" "fmt" ) type IT struct { Company ...

  4. 初次见识结构体与map的区别

    题目  http://vjudge.net/contest/view.action?cid=51142#problem/G 自己做的结构体 #include <iostream>#incl ...

  5. Go 结构体和map等数据结构转json字符串

    Go语言中使用json包中的 Marshal() 函数将数据结构转成json字符串,源代码: func Marshal(v interface{}) ([]byte, error) { e := ne ...

  6. C++ 结构体、模板、类、重载初使用

    目的:需要几个缓存用的数组900*750 首先定义一个模板<参数数据类型,参数1,参数2> 定义一个class类 名字自己取ap_uint0 下面是公用的数组模板[lrow][lcol] ...

  7. C++中,用类和重载运算符写高精模板

    先放代码: #include<iostream> #include<cstdio> #include<cstring> using namespace std; s ...

  8. 用set、map等存储自定义结构体时容器内部判别各元素是否相同的注意事项

    STL作为通用模板极大地方便了C++使用者的编程,因为它可以存储任意数据类型的元素 如果我们想用set与map来存储自定义结构体时,如下 struct pp { double xx; double y ...

  9. STL map、set中key为结构体的用法

    下面是map定义的结构: // TEMPLATE CLASS map template<class _Kty, class _Ty, class _Pr = less<_Kty>, ...

随机推荐

  1. Eclipse添加jsp页面后引入java指令报错解决方法

    新建jsp页面老提示: Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpS ...

  2. PHP换行符详解 PHP_EOL,<br />

    1.PHP_EOL:用于文本的换行符,经常用于日志文件记录.可以解决: 在windows中\r\n是换行在Mac中\r是换行在Liunx中\n是换行 不统一的问题. 2. <br /> : ...

  3. mac 无法ssh localhost

    mac 无法ssh localhost,错误提示:bash: /usr/local/bin/ssh_session: Permission denied在网上找了很久也没有找到解决方案,最后根据提示自 ...

  4. Eclipse中SVN的安装步骤(两种)和使用方法 [转]

    一.给Eclipse安装SVN,最常见的有两种方式:手动方式和使用安装向导方式.具体步骤如下: 方式一:手动安装 1.从官网下载site-1.6.9.zip文件,网址是:subclipse.tigri ...

  5. 学习记录012-NFS

    1.Network file System 主要是通过网络让不同的主机进行通信,构建于ip协议之上的现代文件系统,用来存储共享视频,图片,文件等 2.并发大的时候会有点问题(维护不好会丢数据) 3.N ...

  6. DML数据操作语言练习

    --创建表T_HQ_BM2 --create table t_hq_bm2 as select * from t_hq_bm; commit; --添加行内容 --insert into t_hq_b ...

  7. hdu 4616 Game

    http://acm.hdu.edu.cn/showproblem.php?pid=4616 要记录各种状态的段  a[2][4] a[0][j]表示以trap为起点一共有j个trap的最优值 a[1 ...

  8. 解决:操作无法完成(错误0x00000709)。再次检查打印机名称,并确保打印机已连接到.

    就是重启一下服务器端的Print Spooler服务就行了,这么简单! [控制面板 -  服务 -  Print Spooler]

  9. 都是以父元素的width为参照物的

    本文依赖于一个基础却又容易混淆的css知识点:当margin/padding取形式为百分比的值时,无论是left/right,还是top/bottom,都是以父元素的width为参照物的!也许你会说, ...

  10. X230 安装win7 sp1

    早上起床发现win10歇菜了,死活启动不了只好重装系统 用稳定版本win7比较靠谱. 去msdn上下载 一个win7系统 win7旗舰版本64位 ed2k://|file|cn_windows_7_u ...