首页 > 其他 > 详细

查找重复元素

时间:2020-02-27 09:03:31      阅读:72      评论:0      收藏:0      [点我收藏+]
/**
 * 查找重复元素
 * @author 华伟科技
 */
public class Demo {
	public static void main(String[] args) {
		int[] my_array = { 1, 2, 5, 5, 6, 6, 7, 2, 9, 2 };
		findDupicateInArray(my_array);
	}
	public static void findDupicateInArray(int[] a) {
		int count = 0;
		for (int j = 0; j < a.length; j++) {
			for (int k = j + 1; k < a.length; k++) {
				if (a[j] == a[k]) {
					count++;
				}
			}
			if (count == 1) {
				System.out.println("重复元素 : " + a[j]);
			}
			count = 0;
		}
	}
}

  

查找重复元素

原文:https://www.cnblogs.com/hongwei2085/p/12370194.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!