控制台程序输出传入参数随机时间关闭兼谈随机数

// jcall.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include 
#include 
#include
using namespace std;
using std::default_random_engine;
using std::uniform_int_distribution;
static default_random_engine e(time(nullptr));
uniform_real_distribution u1(1, 4);
static double getrand();
int _tmain(int argc, _TCHAR* argv[])
{
	string st;
	for (int i = 1; i < argc; i++)
	{
		string temp = "\t";
		st += argv[i] + temp;
	}
	cout << "stdcout:  ";
	fprintf(stdout, st.data());
	cout << endl;
	cout << "stderr:  ";
	fprintf(stderr, st.data());
	cout << endl;
	//system("cls");
	double min = getrand();
	min = min * 1000 * 60;
	cout << "休眠"<

程序每次启动获取一个小于5的随机数

#include 
#include
#include
using namespace std;

int main()
{
    srand(time(0));
    for(int x=1;x<25;x++){
       cout << rand()%5)<< endl;
    }

    system("pause");
    return 0;
}

 

你可能感兴趣的:(cpp)