0
点赞
收藏
分享

微信扫一扫

标签【vector学习】:2022年4月12日 22:32:35

young_d807 2022-04-14 阅读 25
c++
#include <stdlib.h> // rand(), srand()
#include <stdio.h> // printf()
#include<Windows.h> 
#include <iostream>
using namespace std;

void RangedRandDemo(int range_min, int range_max, int n,int ts[1])
{
	DWORD start_time = GetTickCount(); 
	for (int i = 0; i < n; i++)
	{
		int r = ((double)rand() / RAND_MAX) * (range_max - range_min) + range_min;
		printf("  %6d\n", r);
	}
	DWORD end_time = GetTickCount();
	ts[0]=(end_time - start_time);
}
int main(void)
{	
	int ts[1];
	RangedRandDemo(-100, 100, 500, ts);
	cout << "The run time is:" <<ts[0]<< "ms!" << endl; 
	system("pause");
}
举报

相关推荐

0 条评论