首页 > 代码库 > acm 2019 用java写
acm 2019 用java写
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in= new Scanner(System.in);
List<Integer> set= new ArrayList<Integer>();
while(true){
int n=in.nextInt();
int m=in.nextInt();
if(n + m == 0){
break;
}
set.clear();
int i=0;
while (i<n){
set.add(in.nextInt());
i++;
}
set.add(m);
ArrayList<Integer> li = new ArrayList<Integer>();
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
li.add((Integer) iterator.next());
}
Collections.sort(li);
int iii= li.remove(li.size()-1);
for(int ii:li){
System.out.print(ii+" ");
}
System.out.print(iii);
System.out.println();
}
}
}
acm 2019 用java写