package cn.jxxy.chapter01;
public class RemoveDuplicateDemo {
public static void main(String args[]) {
int[] numbers = new int[10];
java.util.Scanner input = new java.util.Scanner(System.in
);
System.out.print("Enter ten numbers: ");
for (int i = 0; i < numbers.length; i++) {
numbers[i] = input.nextInt();
}
int[] result = removeDuplicate(numbers);
System.out.println(
"The number of distinct values is " + result.length);
for (int i = 0; i < result.length; i++)
System.out.println(result[i] + " ");
}
public static int[] removeDuplicate(int[] numbers) {
System.out.println("The distinct numbers are:");
int[] removeDuplicate= {1,1,1,1,1,1,1,1,1,1};
for(int i=0; i < numbers.length;i++)
{
for(int j=9; j > numbers.length-1; j--)
{
if(numbers[i]==numbers[j])
{
removeDuplicate[j]=-1;
}
}
for(int i=0;i<numbers.length;i++)
{
if(removeDuplicate[i]==1) {
System.out.print(numbers[i]+"");
}
}
}
慕粉2121432925
谁能给个解释?
看不懂这行代码,谁能解释一下吗
startmove()究竟是什么?运动框架?谁能给我详细解释一下啊!
谁知道老师给整块函数加注释,写这个函数的功能时,用的什么快捷键?
相关分类