srand只需要使用一次即可,将其提到for循环外即可以产生了。srand(time(0)); for (s=0;s<5;s++) { i= rand() %5 ; //产生随机数 cout << i <}
http://zhidao.baidu.com/question/8236829.html