java基础:数组高纳德置乱算法
2021-02-06 16:18
标签:tostring rand java next sys int and ati class import java.util.Arrays; import java.util.Random; public class HomeWork03 { public static void main(String[] args){ int[] arr ={1,5,4,23,65,25,8,10,20,45}; System.out.println("置换前:"+Arrays.toString(arr)); for (int i = arr.length-1; i >0; i--) { int index = new Random().nextInt(i); int temp=arr[i]; arr[i]=arr[index]; arr[index]=temp; } System.out.println("高纳德置乱算法:"+Arrays.toString(arr)); } } java基础:数组高纳德置乱算法 标签:tostring rand java next sys int and ati class 原文地址:https://www.cnblogs.com/C33baby/p/12781372.html