cout快捷转换进制

cout<<hex<<i<<endl; //输出十六进制数
cout<<oct<<i<<endl; //输出八进制数
cout<<dec<<i<<endl; //输出十进制数

cout<<bin<<i<<endl; //输出二进制数

// 输出16进制, setbase(int)可以设置8等。

 cout << setbase(16) << i << endl;

 itoa(x,ss,2);//(待转换数字,空字符串,进制)

猜你喜欢

转载自www.cnblogs.com/shenben/p/10356768.html