国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

c語言隨機數(shù)函數(shù)示例

2020-01-26 15:33:06
字體:
供稿:網(wǎng)友

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.

復(fù)制代碼 代碼如下:

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 谢通门县| 河南省| 衡阳县| 临泽县| 衡阳县| 浠水县| 永济市| 黔东| 平潭县| 林甸县| 恩施市| 邵阳县| 湘乡市| 长治县| 嘉峪关市| 体育| 纳雍县| 凌云县| 上饶市| 朝阳区| 青龙| 乌海市| 江安县| 诸暨市| 林州市| 赤水市| 教育| 读书| 丘北县| 西平县| 广宁县| 博爱县| 侯马市| 正镶白旗| 石城县| 永年县| 杭锦旗| 松江区| 诸城市| 兰州市| 荔波县|