-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.cpp
More file actions
31 lines (26 loc) · 777 Bytes
/
function.cpp
File metadata and controls
31 lines (26 loc) · 777 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
int digit_count(int n) {
if (n == 0) return 1;
return (int)(log10(n)) + 1;
}
vector<string> name_file(int len,const string &folder, const string &prefix,const string &suffix, int width = 1){
width = max(digit_count(len),width);
vector<string> files(len);
for(int i=0;i<len;i++) {
files[i] = folder + prefix + string(width - digit_count(i), '0') + to_string(i)+ suffix;
}
return files;
}
ofstream& n_integers(ofstream& out,int n){
for(int i=0;i<n;i++){
int a = a_dis(rng);
out<<a<<' ';
}out<<'\n';
return out;
}
string str_make(int n,char base='a'){
string out;out.reserve(n);
for(int i=0;i<n;i++){
out.push_back(char(char_dis(rng)+base));
}
return out;
}