[热身题][hdoj_2095]find your present (2)

来源:互联网 发布:怎样推广淘宝店名 编辑:程序博客网 时间:2024/06/04 00:38

// hdoj_2095 find your present (2)// 562MS220K230 BGCC#include <stdio.h>int main(void){int i, n, x, s;while(scanf("%d", &n), n){s = 0;for(i = 0; i < n; i ++){scanf("%d", &x);s ^= x;}printf("%d\n", s);}return 0;}

while(scanf("%d", &n), n) 用到了逗号表达式

s ^= x; 用到了异或运算

百度百科:http://baike.baidu.com/view/674171.htm

1^1 = 0

1^0 = 1

0^1 = 1

0^0 = 0