标题:跪求怎样得到随机数
取消只看楼主
weiC
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2004-8-10
 问题点数:0 回复次数:1 
跪求怎样得到随机数

1:问题如上?

2:如何实现保留两位小数点及如何四舍五入?

搜索更多相关主题的帖子: 随机数 
2004-08-10 20:16
weiC
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2004-8-10
得分:0 
跪求怎样得到随机数

1:

#include <stdlib.h> #include <stdio.h> #include <time.h>

int main(void) { int i; time_t t;

srand((unsigned) time(&t)); printf("Ten random numbers from 0 to 99\n\n"); for(i=0; i<10; i++) printf("%d\n", rand() % 100); return 0; }

2:

#include <stdlib.h> #include <stdio.h> #include <time.h>

int main(void) { int i;

randomize(); printf("Ten random numbers from 0 to 99\n\n"); for(i=0; i<10; i++) printf("%d\n", rand() % 100); return 0; } 3:

#include <stdlib.h> #include <stdio.h> #include <time.h>

/* prints a random number in the range 0 to 99 */ int main(void) { randomize(); printf("Random number in the 0-99 range: %d\n", random (100)); return 0; }

2004-08-25 20:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-4113-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.686804 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved