问题 How can I generate random numbers from 0 to 1000000? I already tried the code below, but it still gives me numbers from 0 to 32767 (RAND_MAX): #include <stdio.h> #include <stdlib.h> #include <time.h> int main(){ int i,x; srand(time(NULL)); for(i=0; i<10000; i++){ int x = rand() % 10000000 + 1; printf("%d\n",x); } return 0; } 回答1: [Edit] The initial answer was for 0 to 1,000,000. I now see it should be 0 to 10,000,000. As rand() will give an answer of at least 15 bits, call rand() multiple