Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ofstream dato("Data.txt", ios::app | ios::out);
- if (dato.fail())
- {
- cout << "Error al crear el archivo :(";
- }
- else
- {
- srand(time(0)); // iniciando la semilla aleatoria
- // Formula a + rand() % (b-a+1)
- // eligiendo 15 numeros aleatorios distintos entre 1 y 50
- for (ie = 0; ie<500; ie++)
- {
- // Genera numero aleatorio
- int num = 1 + rand() % 500;
- if (ie>0)
- {
- // Verifica si no se ha generado antes
- for (je = 0; je < ie; je++)
- if (num == vectore[je])
- {
- num = 1 + rand() % 500;
- je = -1;
- }
- }
- vectore[ie] = num;
- dato << vectore[ie] << endl;
- }
- dato.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement