-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerateEqualData.cpp
More file actions
43 lines (34 loc) · 986 Bytes
/
generateEqualData.cpp
File metadata and controls
43 lines (34 loc) · 986 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
#include <bits/stdc++.h>
#include <fstream>
#include<iostream>
using namespace std;
int main()
{
int min = 1; // Minimum value for the columns
int max = 100; // Maximum value for the columns
int count = 1000; // Number of rows
int cols = 10; // Number of columns per row
// Seed the random number generator
srand(static_cast<unsigned>(time(0)));
ofstream output_file("database.txt");
vector<int> fixedRow(cols);
// Generate a fixed row with random values
for (int j = 0; j < cols; ++j)
{
fixedRow[j] = rand() % (max - min + 1) + min;
}
// Write the same row multiple times
for (int i = 0; i < count; ++i)
{
for (int j = 0; j < cols; ++j)
{
output_file << fixedRow[j];
if (j != cols - 1)
output_file << " ";
}
if (i != count - 1)
output_file << endl;
}
output_file.close();
return 0;
}