-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17.34.cpp
97 lines (78 loc) · 2.22 KB
/
17.34.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <iomanip>
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::boolalpha;
using std::noboolalpha;
using std::showbase;
using std::noshowbase;
using std::showpoint;
using std::noshowpoint;
using std::showpos;
using std::noshowpos;
using std::uppercase;
using std::nouppercase;
using std::dec;
using std::hex;
using std::oct;
using std::left;
using std::right;
using std::internal;
using std::fixed;
using std::scientific;
using std::hexfloat;
using std::defaultfloat;
using std::unitbuf;
using std::nounitbuf;
using std::skipws;
using std::noskipws;
using std::flush;
using std::ends;
using std::endl;
using std::setfill;
using std::setprecision;
using std::setw;
using std::setbase;
int main() {
bool t = true, f = false;
int i = 1234, i2 = -1234;
double d = 1.23456789123, d2 = 1.0;
cout << boolalpha << t << '\t' << f << endl;
cout << noboolalpha << t << '\t' << f << endl;
cout << showbase << hex << i << '\t'
<< oct << i << '\t' << dec << i
<< noshowbase << endl;
cout << showpoint << d << '\t' << d2 << '\n'
<< setprecision(12) << d << '\t' << d2 << '\n'
<< noshowpoint << d << '\t' << d2 << endl;
cout.precision(6);
cout << showpos << i << '\t' << i2 << endl
<< noshowpos;
cout << uppercase << hex << d << nouppercase << dec << endl;
cout << left << setw(24) << i << "|\n"
<< setw(24) << i2 << "|\n"
<< setw(24) << d << "|\n"
<< setw(24) << d2 << '|' << right << endl;
cout << right << setw(24) << i << '|' << endl;
cout << internal << setw(24) << i2 << "|\n"
<< setw(24) << d << '|' << right << endl;
cout << left << fixed << setw(24) << d << d2 << '\n'
<< scientific << setw(24) << d << d2 << '\n'
<< hexfloat << setw(24) << d << d2 << '\n'
<< defaultfloat << setw(24) << d << d2 << endl;
cout << unitbuf << "unitbuf" << " on" << nounitbuf << ", now off" << endl;
cout << flush;
char p[4] = {'e', 'n', 'd', 's'}; // not null-terminated
cout << p << ends << endl;
cout << setfill('#') << setw(24) << i2 << setfill(' ') << endl;
cout << setbase(8) << i << ' ' << i2 << setbase(10) << endl;
cout << "enter something: ";
string text;
cin >> noskipws;
for (char c; cin >> c; text += c) ;
cin >> skipws;
cout << text;
return 0;
}