-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cpp
50 lines (40 loc) · 1.08 KB
/
Utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
class Utils
{
private:
Utils();
public:
static int getTamanhoArquivo(const string nomeArq)
{
std::ifstream in(nomeArq, std::ifstream::ate | std::ifstream::binary);
return in.tellg();
}
static void medirTempo(const time_t inicio)
{
time_t fim;
time(&fim);
// Calculating total time taken by the program.
double time_taken = double(fim - inicio);
cout << "Time taken by program is : " << fixed
<< time_taken << setprecision(5);
cout << " sec " << endl;
}
static void gerarArquivoDados(const string nomeArq, const int qtdNumeros)
{
int min = 1, max = 15000;
ofstream arq(nomeArq);
if(!arq.is_open())
return;
for(int i=0; i<qtdNumeros; i++){
string num = to_string((rand() % max) + min) + " ";
arq.write(num.c_str(), num.length());
}
arq.close();
}
};