程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> c說話隨機數函數示例

c說話隨機數函數示例

編輯:關於C++

c說話隨機數函數示例。本站提示廣大學習愛好者:(c說話隨機數函數示例)文章只能為提供參考,不一定能成為您想要的結果。以下是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());
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved