/ hdoj

hdoj-2095 find your present (2)

// hdoj_2095 find your present (2)
// 562MS	220K	230 B	GCC

#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("%dn", s);
	}
	return 0;
}

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

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

百度百科:异或

1^1 = 0
1^0 = 1
0^1 = 1
0^0 = 0