-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.h
More file actions
77 lines (68 loc) · 1.45 KB
/
Header.h
File metadata and controls
77 lines (68 loc) · 1.45 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef __HEADER_H__
#define __HEADER_H__
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cmath>
#include <stdio.h>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <stdlib.h>
#include <deque>
#include <time.h>
using namespace std;
int random(int x) {
return rand() % x + 1;
}
vector<int> genRandVector(int len, int maxVal){
vector<int> v(len, 0);
srand((int)time(NULL));
for (int i = 0; i < len; ++i)
{
v[i] = random(maxVal);
}
return v;
}
vector<int> genOrderedVector(int len){
vector<int> v(len, 0);
for (int i = 1; i <= len; ++i)
{
v[i-1] = i;
}
return v;
}
vector<string> genStrVector(string str){
vector<string> v;
int i = 0, j;
while (i < str.length()) {
while (i < str.length() && str[i] == ' ') i++;
j = 0;
for (; i+j < str.length() && str[i+j] != ' '; j++);
v.push_back(str.substr(i, j));
i += j;
}
return v;
}
string toString(vector<int> v) {
string res = "[";
for (int i = 0; i < v.size() - 1; i++){
res += to_string(v[i]) + ", ";
}
res += to_string(v[v.size() - 1]) + "]";
return res;
}
string toString(vector<string> v) {
string res = "[";
for (int i = 0; i < v.size() - 1; i++){
res += v[i] + ", ";
}
res += v[v.size() - 1] + "]";
return res;
}
#endif