题解 | #明明的随机数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
记录一下这个do while,简单直接有效,除了有点不够高效
import java.util.*; public class Main{ public static void main(String[] args){ Scanner in =new Scanner(System.in); do{ int N=in.nextInt(); int idx=0; int[] buf=new int[1001]; Arrays.fill(buf,0); while(idx++<N){ int tmp=in.nextInt(); buf[tmp]=buf[tmp]|1; } for(int i=1;i<=1000;++i){ if(buf[i]!=0){ System.out.println(i); } } }while(in.hasNext()); } }