import java.util.Random;标签:顺序,int,打乱,suiji,System,new,工号,out From: https://www.cnblogs.com/nulicheng/p/17847682.html
import java.util.Scanner;
public class suijipaiming {
public static void main(String[] args) {
int[] a =new int[6]; //1.创建6个动态数组
Scanner sc = new Scanner(System.in);
for (int i = 0; i <a.length ; i++) { //2.用户输入(并存入数组)
//遍历每个数组 0 0 0 0 0 0
System.out.println("请输入第"+(i+1)+"个工号");
int yonghu=sc.nextInt(); //用户输入
a[i]=yonghu; //存入数组
}
//生成随机数(索引)
Random ra=new Random(); //3.生成随机数
for (int i = 0; i <a.length; i++) {
int suiji=ra.nextInt(a.length);
int temp = a[suiji]; //建一个临时变量temp,完成转换
a[suiji] = a[i];
a[i] = temp;
}
System.out.println("请按照以下工号循序依次上台"); //4.将结果打印出来
for (int i = 0; i < a.length ; i++) {
System.out.print(a[i]+" ");
}
}
}