在C语言中,“^”是一个双目运算符,用于完成两个数据的按位异或操作。
例如:
5^4 <=> (00000101)^(00000100)=(00000001)=1
用于位运算中,同为0;异为一。
但是^还有一种妙用,如下题:
例题
http://acm.hdu.edu.cn/showproblem.php?pid=2095
D - find your present (2)
In the new year party, everybody will get a “special present”.Now it’s your turn to get your special present, a lot of presents now putting on the desk, and only one of them will be yours.Each present has a card number on it, and your present’s card number will be the one that different from all the others, and you can assume that only one number appear odd times.For example, there are 5 present, and their card numbers are 1, 2, 3, 2, 1.so your present will be the one with