就跟数字出现奇数次道理是一样的,将一个数转化为2进制后找出现奇数次个1的位置,最后将其输出来便是出现奇数次的数

 

#include <cstdio>

int main()
{
    int n,a;
    while(scanf("%d",&n)!=EOF){

        int res=0;
        for(int i=0;i<n;i++){
            scanf("%d",&a);
            res^=a;
        }
        printf("%d\n",res);

    }
    return 0;
}

 

 posted on 2014-09-08 15:58  Love风吟  阅读(111)  评论(0编辑  收藏  举报