-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPRINT-EVERYTHING.cpp
70 lines (53 loc) · 1.31 KB
/
PRINT-EVERYTHING.cpp
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
void print() {
printf("%c", 'c');
cout << endl; // ok
cout << "\n"; // better sometimes for performance
cout << 'a' << "\n";
cout << "abc" << "\n";
cout << 1 << "\n";
cout << "[" << 100 << "," << 200 << "]" << "\n";
cout << setw(10) << 100 << "\n";
cout << setw(10) << setfill('-') << 100 << "\n";
string s1 = "hello";
cout << s1 << "\n";
stringstream output1;
output1 << "hello" << "\n";
output1 << "world" << "\n";
cout << output1.str();
}
template <class T>
void printA(T *A, size_t N, bool bNewLine = true) { // print A[]
for (size_t i = 0; i < N; i++) {
cout << A[i] << " ";
}
if (bNewLine) {
cout << "\n";
}
}
template <class T>
void printVD(T c1, bool bNewLine = true) { // print vector<T>, deque<T>
for (size_t i = 0; i < c1.size(); i++) {
cout << c1[i] << " ";
}
if (bNewLine) {
cout << "\n";
}
}
template <class T>
static void printVVDD(T vv1, bool bNewLine = true) { // print vector<vector<T>>, deque<deque<T>>
for (size_t i = 0; i < vv1.size(); i++) {
printVD(vv1[i], bNewLine);
}
if (bNewLine) {
cout << "\n";
}
}
template <class T>
static void printM(const T &m1, bool bNewLine = true) { // print map<T>
for (auto kv1 : m1) {
cout << kv1.first << " " << kv1.second << endl;
}
if (bNewLine) {
cout << "\n";
}
}