gpt4 book ai didi

c语言随机数函数示例

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 26 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章c语言随机数函数示例由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

void srand( unsigned int seed ); head file is <stdlib.h> Remarks The srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.   。

复制代码 代码如下:

#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());
}

最后此篇关于c语言随机数函数示例的文章就讲到这里了,如果你想了解更多关于c语言随机数函数示例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com