题解 | #明明的随机数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.Scanner;
public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); while(input.hasNextLine()){ int[] arr = new int[501]; int n = Integer.parseInt(input.nextLine()); while(n-- > 0){ int val = Integer.parseInt(input.nextLine()); if(val >= 1 && val <= 500 && arr[val] == 0) { arr[val] = val; } } for (int i = 0; i < arr.length; i++) { if(arr[i] != 0){ System.out.println(arr[i]); } } } } }