标题:问题“随机产生一个整数怎么实现”
只看楼主
chen44845023
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2009-7-14
结帖率:0
已结贴  问题点数:20 回复次数:1 
问题“随机产生一个整数怎么实现”
在一个VC环境中,
在一个程序中如何才能产生一定范围的随机整数?

[[it] 本帖最后由 chen44845023 于 2009-7-14 17:42 编辑 [/it]]
搜索更多相关主题的帖子: 整数 随机 
2009-07-14 17:21
radcat
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:306
专家分:45
注 册:2006-9-12
得分:20 
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

void main( void )
{
int i;
/* Seed the random-number generator with current time so that
   the numbers will be different every time we run.
    */
srand( (unsigned)time( NULL ) );
/* Display 10 numbers. */
for( i = 0;   i < 10;i++ )
printf( “  %6d\n”, rand() );
}
MSDN是一定要装的

2009-07-14 20:19



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




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

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