HDU 2095 find your present (2)( 位运算 )
**链接:****传送门 **
题意:给出n个数,这n个数中只有一种数出现奇数次,其他全部出现偶数次,让你找到奇数次这个数
思路:简单异或运算题
/*************************************************************************
> File Name: hdu2095.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月10日 星期三 15时47分03秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
int n,x;
int main(){
while(~scanf("%d",&n) && n){
scanf("%d",&x);
int tmp = x;
for(int i=1;i<n;i++){
scanf("%d",&x);
tmp ^= x;
}
printf("%d\n",tmp);
}
return 0;
}
如要转载请注明转载出处:http://www.cnblogs.com/WArobot