From 9cf6149921896099c4ecba02d214e6020e60d807 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 7 May 2016 20:56:51 +0800 Subject: [PATCH] Create 12504_Richr_Wong.cpp From http://blog.csdn.net/Richr_Wong/article/details/50193361 --- UVA/12504_Richr_Wong.cpp | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 UVA/12504_Richr_Wong.cpp diff --git a/UVA/12504_Richr_Wong.cpp b/UVA/12504_Richr_Wong.cpp new file mode 100644 index 0000000..43f0643 --- /dev/null +++ b/UVA/12504_Richr_Wong.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +using namespace std; +char bufold[1000],bufnnew[1000]; +string key,value; +mapold,nnew; +map::iterator it; +setadd,sub,cha; +set::iterator itt; +inline void filter(char *str,int n){ + for(int i=0;i>n; + getchar(); + while(n--) + { + gets(bufold); + gets(bufnnew); + filter(bufold,strlen(bufold)); + filter(bufnnew,strlen(bufnnew)); + istringstream oldin(bufold); + istringstream nnewin(bufnnew); + old.clear();nnew.clear(); + while(oldin>>key>>value)old[key]=value; + while(nnewin>>key>>value)nnew[key]=value; + add.clear();sub.clear();cha.clear(); + for(it=nnew.begin();it!=nnew.end();it++) + if(old.find(it->first)==old.end())add.insert(it->first); + for(it=old.begin();it!=old.end();it++) + if(nnew.find(it->first)==nnew.end())sub.insert(it->first); + for(it=nnew.begin();it!=nnew.end();it++) + if(old.find(it->first)!=old.end()&&old[it->first]!=it->second) + cha.insert(it->first); + if(add.empty()&&sub.empty()&&cha.empty()){ + cout<<"No changes"<