上课突然想起来个洗牌算法,记一下

for(int i = n - 1; i >= 0 ; i -- )  
             swap(arr[i], arr[rand(0, i)])

关于给字符型数组赋值的方法//带炮哥带我长见识了@广西大学黄毅然

Scanner scanner = new Scanner(System.in);
char[] c = null;
while (true) {
    
    
c = scanner.next().toCharArray();
System.out.println("您输入的char数组为:");
for (int i = 0, len = c.length; i < len; i++) {
    
    
System.out.print(c[i] + " ");
}
System.out.println();
}

猜你喜欢

转载自blog.csdn.net/qq_45864370/article/details/108851670
今日推荐