标签:
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <stack> #include <queue> #include <string> #include <vector> #include <map> #include <algorithm> const int inf = 0x3f3f3f; const int MAXN = 2e2+10; using namespace std; int main() { int n,a; map<int,int>hash; map<int,int >::iterator li; while(scanf("%d",&n)!=EOF&&n){ hash.clear(); for(int i=0;i<n;i++){ scanf("%d",&a); hash[a]++; } for(li=hash.begin();li!=hash.end();li++){ if(li->second==1){ printf("%d\n",li->first); break; } } } //cout << "Hello world!" << endl; return 0; }
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <stack> #include <queue> #include <string> #include <vector> #include <map> #include <algorithm> const int inf = 0x3f3f3f; const int MAXN = 2e2+10; using namespace std; int main() { int n,a,t; //map<int,int>hash; //map<int,int >::iterator li; while(scanf("%d",&n)!=EOF&&n){ //hash.clear(); t = 0; for(int i=0;i<n;i++){ scanf("%d",&a); t ^= a; } /*for(li=hash.begin();li!=hash.end();li++){ if(li->second==1){ printf("%d\n",li->first); break; } }*/ cout<<t<<endl; } //cout << "Hello world!" << endl; return 0; }
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <stack> #include <queue> #include <string> #include <vector> #include <map> #include <algorithm> const int inf = 0x3f3f3f; const int MAXN = 2e2+10; using namespace std; int a[MAXN],b[MAXN];//b[]第一次出现的数字位置记录该数字出现的频率 int main() { int n; int j; //map<int,int>hash; //map<int,int >::iterator li; while(scanf("%d",&n)!=EOF&&n){ //hash.clear(); memset(b,0,sizeof(b)); for(int i=0;i<n;i++){ scanf("%d",&a[i]); for(j=0;j<i;j++){ if(a[i]==a[j]){ b[j]++; break; } } if(j==i) b[j]++; } /*for(li=hash.begin();li!=hash.end();li++){ if(li->second==1){ printf("%d\n",li->first); break; } }*/ for(int i=0;i<n;i++){ if(b[i]==1){ cout<<a[i]<<endl; break; } } } //cout << "Hello world!" << endl; return 0; }
标签:
原文地址:http://www.cnblogs.com/EdsonLin/p/5490843.html