国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表

圖片精選

主站蜘蛛池模板: 汽车| 天台县| 兴仁县| 安泽县| 偃师市| 田林县| 临沂市| 怀柔区| 池州市| 阜南县| 保靖县| 应城市| 融水| 五常市| 田林县| 桃源县| 叶城县| 鄂托克前旗| 郑州市| 郯城县| 油尖旺区| 望都县| 西和县| 荆州市| 苍山县| 青海省| 金秀| 青阳县| 武陟县| 桑植县| 商城县| 邻水| 西安市| 天水市| 高邮市| 肇源县| 屏山县| 宝应县| 淮北市| 大渡口区| 广平县|