问题:从键盘中输入一些整数,输出不重复的整数
public class Ping {public static void main(String[] args) {
//打印不同的数
Scanner input = new Scanner(System.in);
System.out.print("Please input the number:");
int number = input.nextInt();
System.out.print("Please input some integers:");
int[] a = new int[number];
int[] b = new int[number];
for(int i = 0;i < number;i++) {
a[i] = input.nextInt();
}
int count = 0;
int k,w;
for(k = 0;k < number;k++) {
for(w = 1;w <= number;w++) {
if(a[k] != a[w]) {
b[count] = a[k];
count++;
}
}
/*
if(count >= 1)
count = 0;
else
b[k] = a[k];
*/
}
int len = b.length;
for(int i = 0;i < count;i++) {
System.out.print(b[i] + " ");
}
System.out.println();
System.out.println(len);
input.close();
}
}
有错误,但是我觉得我的想法没有错
求解答