有一个单词库,随机抽出一个单词,把单词打乱,让用户拼写单词。
  
请各位高手指点一下,附上具体的 解题思路。谢谢了

解决方案 »

  1.   

    http://www.hk-18p2p.cn/hk/?fromuid=18190
      

  2.   

    我现在是刚学JAVA这道题是老师让我们做的作业,我现在就是在怎么把单词字幕打乱这里 卡住了 ,比如:随机抽出的单词是hello,怎么把这个单词打乱!请各位指点。谢谢了
      

  3.   

    可以将string先变成char数组
    再将数组打乱,用Math.random();
      

  4.   

    设置数组,然后用数组下标Math.random();
      

  5.   

    import java.util.Random;public class Test {

    public static void main(String[] args) {
    String s = "hello";
    char[] cs = s.toCharArray();
    charRandom(cs);
    System.out.println(String.valueOf(cs));
    }

    public static void charRandom(char[] c) {
    int al = c.length;
    Random ran = new Random();
    for(int i = 0; i < 100; i++) {
    int ranInt_1 = ran.nextInt(al);
    int ranInt_2 = ran.nextInt(al);
    if(ranInt_1 != ranInt_2) {
    char temp = 0;
    temp = c[ranInt_1];
    c[ranInt_1] = c[ranInt_2];
    c[ranInt_2] = temp;
    }
    }
    }

    }