题解 | 明明的随机数
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 int a = in.nextInt(); int i =0; int temp; int s[] = new int[a]; while(i<a){ int b = in.nextInt(); s[i]=b; i++; } for(int x =0;x<a;x++){ for(int y =0;y<a-1;y++){ if(s[y]>s[y+1]){ temp = s[y]; s[y] = s[y+1]; s[y+1] = temp; } } } System.out.println(s[0]); for(int z=1;z<s.length;z++){ if(s[z]!=s[z-1]){ System.out.println(s[z]); } } } }