-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp-io.tex
54 lines (45 loc) · 1.3 KB
/
cpp-io.tex
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
\begin{lstlisting}[language=C++]
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <limits>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const int iMAX = numeric_limits<int>::max();
const int iMIN = numeric_limits<int>::min();
const double eps = 1e-9;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
int main() {
// massively improve cout and cin performance for large streams
ios::sync_with_stdio(false);
cin.tie(0);
// Ouput a specific number of digits past the decimal point, in this case 5
cout.setf(ios::fixed); cout << setprecision(5);
cout << 100.0/7.0 << endl;
cout.unsetf(ios::fixed);
// Output the decimal point and trailing zeros
cout.setf(ios::showpoint);
cout << 100.0 << endl;
// Output a '+' before positive values
cout.setf(ios::showpos);
cout << 100 << " " << -100 << endl;
// Output numerical values in hexadecimal
cout << hex << 100 << " " << 1000 << " " << 10000 << dec << endl;
}
\end{lstlisting}