-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerarArchivo.C
More file actions
executable file
·49 lines (42 loc) · 838 Bytes
/
GenerarArchivo.C
File metadata and controls
executable file
·49 lines (42 loc) · 838 Bytes
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
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc, char *argv[])
{
srand(time(NULL));
if(argc != 3)
{
cout<<"Error: <nombreArchivo> <cantidadDatos>"<<endl;
return 1;
}
string nombreArchivo = argv[1];
int cantidadDatos = atoi(argv[2]);
cout<<"Nombre Archivo: "<<argv[1]<<endl<<"Cantidad de datos: "<<argv[2]<<endl;
if(cantidadDatos < 1)
{
cout<<"Error: Cantidad Negativa"<<endl;
return 1;
}
ofstream arch;
clock_t ini;
clock_t fin;
arch.open(nombreArchivo.c_str());
if(!arch)
{
cout<<"Error: NO Abrio el archivo "<<nombreArchivo<<endl;
}
else
{
ini = clock();
for(int i = 0; i < cantidadDatos; i++)
{
arch<<rand()<<endl;
}
arch.close();
fin = clock();
}
cout<<"Tiempo: "<<(fin - ini)/1000<<" ms"<<endl;
return 0;
}