-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathgenerator.cc
More file actions
39 lines (36 loc) · 1 KB
/
generator.cc
File metadata and controls
39 lines (36 loc) · 1 KB
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
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <ctime>
using namespace std;
string intToString(int n) {
string s = "315010";
int bit_count = 0;
int t = n;
while (t > 0) {
bit_count++;
t /= 10;
}
while (bit_count < 4) {
s += "0";
bit_count++;
}
stringstream ss;
ss << n;
s += ss.str();
return s;
}
int main() {
char characters[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
ofstream ofs("/Users/yusen/Documents/Github/miniSQL/test_file");
srand((unsigned)time(NULL));
for (int i = 1;i < 1000;i++) {
ofs << "insert into test values(";
string s = intToString(i);
ofs << "'" << s << "',";
ofs << "'" << characters[rand() % 26] << characters[rand() % 26] << characters[rand() % 26] << "',";
ofs << rand() % 8 + 18 << ",";
ofs << rand() % 5 + (rand() % 6) * 0.2 << ");" << endl;
}
}