hdu 2095 find your present (2)(^的有趣应用)
#include<stdio.h> int main() { int n; int tmp,x; while(scanf("%d",&n)!=EOF&&n!=0) { tmp=0; for(int i=0;i<n;i++) { scanf("%d",&x); tmp^=x; //printf("#%d\n",tmp); } printf("%d\n",tmp); } return 0; }
#include<stdio.h> int main() { int n; int tmp,x; while(scanf("%d",&n)!=EOF&&n!=0) { tmp=0; for(int i=0;i<n;i++) { scanf("%d",&x); tmp^=x; //printf("#%d\n",tmp); } printf("%d\n",tmp); } return 0; }