.................

一个数组中除了某个数,其余的数字均出现俩次,找出只出现一次的数字

package _1_Bit_Operation;

/**
 * @Auther: YuanJun
 * @Date: 2021/12/9 - 12 - 09 - 8:48
 * @Description: _1_Bit_Operation
 */

//一个数组中除了某个数,其余的数字均出现俩次,找出只出现一次的数字

public class test5 {
    //这是一个main方法,是程序的入口:
    public static void main(String[] args) {
        int [] a = new int[]{1,2,3,4,5,6,7,8,7,6,5,4,3,2,1};
        int temp = 0;
        for (int i = 0; i < a.length; i++) {
            temp = temp^a[i];
        }
        System.out.println(temp);
    }
}

 

 

posted on 2021-12-09 10:19  么么^  阅读(3)  评论(0编辑  收藏  举报

Live2D