题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//输入流
String str=null;
//空字符串
while((str=br.readLine())!=null){//输入不为空时进行
int b[]=new int[500];//创建长为500数组
int n=Integer.parseInt(str);//把第一个数据强制转换为int型,一共有n个数
for(int i=0;i<n;i++){//循环n组
String indexStr=br.readLine();//读取输入流,放到字符串indexStr中
int index=Integer.parseInt(indexStr);//转换为int型
b[index]=1;//将index作为数组索引,改索引元素值=1
}
for(int i=0;i<b.length;i++){//遍历
if(b[i]==1){//找出数组元素值为1的数组
System.out.println(i);//输出
}
}
}
}
}
