您的位置:首页 > 编程语言 > C语言/C++

c语言生成 o~100随机数!

2016-02-25 20:45 323 查看
还在学习中,先贴上代码,等待以后自己解答,第二种为什么编译失败!

#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中编译失败!

int i=0;
srand((unsigned)time(NULL));
int chosen=0;
for(;i<100;i++){
chosen=1+rand()%100;
printf("生成随机数:%d \n",chosen);
}
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: