⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 random.cpp

📁 数据结构常用算法合集
💻 CPP
字号:
//random.cpp
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>	//time_t
void main(void)
{
  int i;
  cout << "未使用srand:\n";
  cout<"产生10个 0 到 99的随机数如下:\n";
  for(i=0; i<10; i++)
    cout<<random(100)<<' ';
  cout << "\n使用srand:\n";
  srand(100);
  for(i=0; i<10; i++)
    cout<<random(100)<<' ';
  cout << "\n让srand使用time:\n";
  time_t t;
  srand((unsigned)time(&t));	//与使用randomize()相似
  for(i=0; i<10; i++)
    cout<<random(100)<<' ';
  getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -