  
|
亂數 - 隨機亂數
搭配時間函式,產生20組隨機亂數。
time(NULL)可回傳,從格林威治時間 1970年1月1號 0時0分0秒開始到現在的秒數。- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- for(int i=1; i<=20; i++)
- cout<<rand()<<endl;
- system("pause");
- return 0;
- }
複製代碼 |
|