se detalla:
diciembre decimal como cout<<dec<<b
será convertido a decimal y luego b de salida
El hexadecimal hexagonal cout<<hex<<b
se convertirá en la re-salida hexadecimal b
Como es octal octubre cout<<oct<<b
se convertirá en un re-salida octal b
Ejemplo 1:
#include<iostream>
using namespace std;
int main() {
int n = 16;
cout << dec << n << endl;
cout << oct << n << endl;
cout << hex << n << endl;
return 0;
}
//输出:16 20 10
Ejemplo 2:
El formato predeterminado es decimal dec, antes de modificar el formato del formato original permanecerá en vigor. Uso hexagonal y valor decimal formato hexadecimal octal octubre 42
void hexoct2(void)
{
int chest=42;
int waist=42;
int inseam=42;
cout<<"monsieur cuts a striking figure!"<<endl;
cout<<"chest="<<chest<<" (decimal for 42)"<<endl;
cout<<hex;//manipulator for changing number base
cout<<"waist="<<waist<<" (hexadecimal for 42)"<<endl;
cout<<oct;//manipulator for changing number base
cout<<"inseam="<<inseam<<" (octal for 42)"<<endl;
cin.get();
}
Tomado de:
Referencia 1
Referencia 2
Referencia 3
si equivocadas, cartas privadas I, a retirar inmediatamente