#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;}}
Example: # include <map> # include <iostream> # include <string> using namespace STD; // student information typedef struct tagstudentinfo {int NID; string strname; bool operator <(const tagstudentinfo & A) const {If (NID <. NID) return true; // compare NID if (nid =. NID) return strname. compare (. strname) <0; // compare strname return false;} studentinfo, * pstudentinfo;
Struct is used for map. operators must be reloaded when set. <