-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheat_sheet.txt
47 lines (32 loc) · 1.2 KB
/
cheat_sheet.txt
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
printf
%[flags][width][.precision][length]specifier
flags
0 Left-pads the number with zeroes (0) instead of spaces
-----
DIFF
This example will do what you need :
diff --side-by-side --suppress-common-lines FILE_A FILE_B
And if you use it often you can make a personalized alias for it.
alias diffs='diff --side-by-side --suppress-common-lines'
---
sort descending
std::greater<int>()
std::sort(numbers.begin(), numbers.end(), std::greater<int>());
------
string s;
while(getline(cin, s, '\t')){
// Do something with the line
}
If the delimiter is found, it is extracted and discarded, i.e. it is not stored and the next input operation will begin after it.
-----
cin.ignore(1)
cin.ignore(256,EOF)
cin.ignore(10,'\n')
if using cin and getline, remember that CIN does NOT consume \n
-------
for most graph problems use adjmatrix[][]
or adjlist vector<vector <int> > or vector<int> graph[];
but for
MST (Kruskal) use only priority_queue<pair<int,pair<int,int> > > (weight,node1,node2)
Dijkstra adjlist + priority_queue<best_dist_so_far_tothisnode,node>
sorted by weight: priority_queue<pair<int,int>,vector<pair<int,int> >, greater<pair<int,int> > > reachedNodes; // <best_dist_so_far_tothisnode,node>