[C++] 随机数生成 →→→→→进入此内容的聊天室

来自 , 2021-02-06, 写在 C++, 查看 148 次.
URL http://www.code666.cn/view/d47268e9
  1.  
  2.  
  3. #include <iostream>  
  4. using namespace std;  
  5. #include <stdlib.h>  
  6. #include <time.h>  
  7.  
  8. int getrand(int max) {
  9.         return rand()%max;
  10. }
  11.  
  12. int main()  
  13. {  
  14.     int i;  
  15.     srand((unsigned)time(NULL));  
  16.     for (i=0; i<10; i++)          
  17.     {  
  18.         cout<<getrand(100)<<endl;  
  19.     }  
  20.     cout<<endl;  
  21.     return 0;  
  22. }  
  23.  

回复 "随机数生成"

这儿你可以回复上面这条便签

captcha