還在學習中,先貼上代碼,等待以後自己解答,第二種爲什麼編譯失敗!
#include <stdio.h>
#include <limits.h>#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#define BOOL int
#define TRUE 1
#define FALSE 0
int main(void)
{
//正確的
/*
int chosen=0;int i=0;
srand((unsigned)time(NULL));
for(;i<100;i++){
chosen=1+rand()%100;
printf("生成隨機數:%d \n",chosen);
}*/
// vc中編譯失敗!
srand((unsigned)time(NULL));
int chosen=0;
for(;i<100;i++){
chosen=1+rand()%100;
printf("生成隨機數:%d \n",chosen);
}
return 0;
}