#include <iostream>
using namespace std;
enum Esc {BEL='\a', BSP='\b', NEW='\n', RET='\r', TAB='\t' }; //;
enum Errors { OK, ER_FILE, ER_VALUE }; //;
int main (void)
{
cout << static_cast<char>(NEW) << endl;
return OK;
}
, , . , , .
1.8.
++ cin cout, <iostream>. . . cin , cout, , cin , cout .
, - , <<, >>. printf() scanf(), , .. . , , .
, .. . , , .
1.4. .
#include <iostream>
using namespace std;
int main (void)
{
char c;
int i;
cout << "enter char x and int y" << endl;
cin >> c >> i;
cout << "c = " << c << endl << "i = " << i << endl;
return 0;
}
, , .
endl, \n . , <iomanip> , .
1.5. .
#include <iostream>
#include <iomanip>
using namespace std;
int main (void)
{
const bool x = true;
cout << boolalpha << x << " or " << noboolalpha << x << endl;
|
|
const unsigned int y = 15;
cout << "hex: " << hex << y << endl;
cout << "oct: " << oct << y << endl;
cout << "dec: " << dec << y << endl;
double z = 1234567889e-9;
cout << z << endl;
cout << left << setw(10) << setfill('0') << z << endl;
cout << right << setw(10) << setfill('0') << z << endl;
cout << setprecision(9) << z << endl;
cout << noshowpoint << 1.0 << endl;
cout << showpoint << 1.0 << endl;
return 0;
}
1.4. .
boolalpha / noboolalpha | true, false 1, 0 |
hex / dec / oct | , , |
setprecision() | |
setw() | |
setfill() | |
internal | |
left / right | |
showpoint / noshowpoint | |
showpos | + |
skipws / noskipws | , |
ws | |
uppercase | , E X |
scientific / fixed |
. ignore() . clear() , , goodbit . ; goodbit good().
1.6. .
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main (void)
{
int iter;
cin >> iter; // ;
cout << cin.good() << endl; // ;
cin.clear(ios::goodbit); // good;
cin.ignore(1, '\n'); // ;
cin >> iter; // ;
cout << endl;
return 0;
}
1.9.
, . , , , .
. . , . , ().
, . =. : , , , .
1.9.1.
|
|
: +, , *, /, %. : , ++ .