for(i=0;i<h;i++) { srand(time(0)); b[i]=rand()%3; } 在这个循环中b[i]不变 怎样才能让它变化?
走同样的路,发现不同的人生
b[i] must not change in the loop, because you will initialize PRNG every time you loop. srand(time(0)); should be placed outside the loop.
srand(time(0));
srand(time(0)); for(i=0;i<h;i++) { b[i]=rand()%3; }
b[i] must not change in the loop, because you will initialize PRNG every time you loop.
srand(time(0));
should be placed outside the loop.