-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasicpoints.cpp
More file actions
28 lines (22 loc) · 879 Bytes
/
basicpoints.cpp
File metadata and controls
28 lines (22 loc) · 879 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
//Source : https://stackoverflow.com/questions/5739937/using-getlinecin-s-after-cin
//Incorrect code
int t;
cin >> t;
string s;
getline (cin, s);
// The above code will not read the input string because it will read the '\n' left in cin's buffer //
//Correct code
int t;
cin >> t;
cin.ignore();
string s;
getline (cin , s);
/ *** /
Never traverse a set and erase side by side. First find the values to be erased and then erase.
/ *** /
//Source : https://stackoverflow.com/questions/213907/c-stdendl-vs-n
//Difference between '\n' and endl
//Though both is used to start from the next line, but '\n' doesnot empty the buffer, i.e doesnot flushes
//the output buffer whereas endl does.
//So use '\n' to print from next line whenever flushing is not required, as it reduces the time. Sometimes using endl to print ans to a large number
//of queries might lead to TLE