Obviously want to ask some students in school to do a questionnaire survey, in order to the objectivity of the experiment, he first used a computer to generate N 1 to 1000 random integer (n≤100), for the repeated numbers, only one, the rest of the same number is removed, the different numbers correspond to different student's number. Then the numbers from small to large sorting, in line with the order to find students to do the investigation. Please help clearly to complete the "go to Heavy" and "sort" work. Input Param N Enter the number of random numbers inputarray n random integer array Return Value outputarray output after processing Random integer Note: The test case guarantees the correctness of the input parameters and the answer does not need to be verified.
importjava.util.*;
public
class
Main{
public
static
void
main(String[] args){
Scanner in =
new
Scanner(System.in);
while
(in.hasNextInt()){
Set<Integer> set =
new
HashSet<>();
int
n = in.nextInt();
for
(
int
i=
0
;i<n;i++){
set.add(in.nextInt());
}
List<Integer> list =
new
ArrayList<>();
list.addAll(set);
Collections.sort(list);
for
(
int
i:list){
System.out.println(i);
}
}
}
}Import java.util.*;
/**
* Created by Huaxia Ziyun on 2015/11/23.
*/
public class Main {
public static void Main (string[] args) {
Scanner sc=new Scanner (system.in);
while (Sc.hasnext ()) {
int N=sc.nextint ();
Hashset<integer> hashset=new hashset<integer> ();
for (int i=0;i<n;i++) {
Hashset.add (Sc.nextint ());
}
Arraylist<integer> arraylist=new arraylist<integer> ();
Iterator<integer> Iterator=hashset.iterator ();
while (Iterator.hasnext ()) {
Arraylist.add (Iterator.next ());
}
Collections.sort (arrayList);
StringBuffer sb=new StringBuffer ();
for (int i=0;iSb.append (Arraylist.get (i) + "");
System.out.println (Arraylist.get (i));
}
System.out.println (Sb.substring (0,sb.length ()-1));
}
}
Enter a few numbers first 512 34 12 56 78 output 12 34 56 78
Go re-order