import java.util.Scanner;public class Exer0908 {public static void main(String[] args) {System.out.println("请出入正整数,并以,隔开");Scanner scan = new Scanner(System.in);String str = scan.next().toString();String arr[] = str.split(",");int[] array = new int[arr.length];for (int i = 0; i < array.length ; i++) {array[i] = Integer.parseInt(arr[i]);}for (int i = 0; i < array.length - 1; i++) {for (int j = 0; j < array.length - 1 - i; j++) {if (array[j] > array[j + 1]){int temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;}}}int count = 0;System.out.print("重复数字为:");for (int i = 0; i <array.length - 1; i++) {if (array[i] == array[i + 1]){System.out.print(array[i] + "\t");count++;}}if (count == 0){System.out.println("无重复数字");}}}
请出入正整数,并以,隔开9,2,7,8,4,2,7重复数字为:27
Java Exer0908 从键盘输入皆为正整数的数组元素 数组长度不确定 请找出数组中重复的数字并输出。