tips:这是我抄别人的,我自己写了24行...
补充用C++处理不同进制数的方法。
cin>>oct>>n; 输入八进制 cin>>hex>>n; 输入十六进制.
使用hex和oct以上述三种格式显示十进制值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(); }