现在的位置: 首页 > 综合 > 正文

hdu – 2095 – find your present (2)(异或)

2019年08月28日 ⁄ 综合 ⁄ 共 230字 ⁄ 字号 评论关闭

题意:n(1<=n<1000000) 个数字,其中只有一个数字出现奇数次,求这个数。

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2095

——>>

#include <cstdio>

int main()
{
    int n, a;

    while (scanf("%d", &n) == 1 && n)
    {
        int ret = 0;

        while (n--)
        {
            scanf("%d", &a);
            ret ^= a;
        }

        printf("%d\n", ret);
    }

    return 0;
}

抱歉!评论已关闭.