你可以在循环的内外用System.out.println();看程序什么地方没有执行到。是不是取数据的类型不对呀,以前我遇到过这样的问题,就是取数据的时候类型不对,一点点的调的。

解决方案 »

  1.   

    to   beyond_xiruo(乱谈情)      数据库没有受阻
    to   dingbs(笨苯)
        数据类型也是正确的  我确保
    int select[] = new int[selectCount];
     for(int i=0;i<selectCount;i++)
     {
     retry:
    while(selectCount!=0&&questionCount!=0&&selectCount<=questionCount)
    {
    int tmp = (int)(Math.random() * (double)questionCount)+1;
    for(int j=0;j<i;j++)
    if(select[j]==tmp) continue retry;
        select[i] = tmp ;
    break;
    }   // end while
     }      //end for
        return select;
       }如果改成这样的话,可以有结果,不过结果有重复的,而且
    int tmp = (int)(Math.random() * (double)questionCount)+1
    按理说是取 1到  questionCount  的随机数,
    可是事实上不是的,比如我的  questionCount  =10
    他可以取到  24 去知道是为什么??
      

  2.   

    随机数建议用下面的方法:
    java.unti.Random random=new java.util.Random();
    int i=random.nextInt();
      

  3.   

    int select[] = new int[selectCount];
    //这里声明了select数组并全部初始化为0,
    select[j]==RS.getInt("ID"))
    如果数据库取出来的都不为0,
    那结果就是false,
    所以,selNext永远等于零.
    根据
    if(!selectNext||selNext==0)
        continue retry;
    判断,程序为死循环.
      

  4.   

    哦 to   george_yingjun(竹子)     估计是你说的
    等我回去之后 我一定试一试  谢谢大家了
      

  5.   


    <%
    out.println((int)(Math.random()*(b-a+1))+a);
    %>
    产生a-b的随机数