-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cpp
More file actions
51 lines (43 loc) · 877 Bytes
/
Helper.cpp
File metadata and controls
51 lines (43 loc) · 877 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
44
45
46
47
48
49
50
51
#include "../include/Helper.h"
string convertNumberToBinary(int n, int len){
string answer = "";
while (n != 0) {
answer = to_string(n%2) + answer;
n = n/2;
}
while (answer.size() < len)
answer = '0' + answer;
return answer;
}
string convertNumberToBinarySimple(int n){
string answer = "";
while (n != 0) {
answer = to_string(n%2) + answer;
n = n/2;
}
return answer;
}
//Returns true if two vectors are equal
bool twoVectorsEqual(vector<int> v1, vector<int> v2){
if(v1.size() == v2.size()){
for(int i=0;i<v1.size();i++){
if(v1.at(i) != v2.at(i)){
return 0;
}
}
return 1;
}
return 0;
}
//Printing an <int> vector and a <string> vector
void printVector(vector<int> v){
for(int i=0;i<v.size();i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
void printStringVector(vector<string> v){
for(int i=0;i<v.size();i++){
cout<<v[i]<<endl;
}
}