1 public class singleNum { 2 /* 3 * 因为a^b^a=b,所以1^2^2^3^3=1 4 * 5 * */ 6 7 public int single(int A[]) 8 { 9 int aim,i; 10 for(aim=0,i=0;i<A.length;i++) 11 { 12 aim=aim^A[i]; 13 } 14 return aim; 15 } 16 17 public static void main(String[] args) 18 { 19 20 int A[]={1,2,3,3,2}; 21 singleNum sn=new singleNum(); 22 int num=sn.single(A); 23 System.out.println(num); 24 25 } 26 }