题解 | #明明的随机数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] arrn = new int[n];
int[] old = new int[501];
for (int i = 0; i < n ; i++){
arrn[i] = scanner.nextInt();
}
for(int i = 0; i < arrn.length; i++){
if(old[arrn[i]] == 0) {
old[arrn[i]] = arrn[i];
}
}
for (int i = 0; i<old.length;i++) {
if (old[i] != 0) {
System.out.println(old[i]);
}
}
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] arrn = new int[n];
int[] old = new int[501];
for (int i = 0; i < n ; i++){
arrn[i] = scanner.nextInt();
}
for(int i = 0; i < arrn.length; i++){
if(old[arrn[i]] == 0) {
old[arrn[i]] = arrn[i];
}
}
for (int i = 0; i<old.length;i++) {
if (old[i] != 0) {
System.out.println(old[i]);
}
}
}
}