📄 demo_2_io_format_1_a.cpp
字号:
//***************************************************
// 用操纵符进行格式化输出
//***************************************************
# include <iostream.h>
# include <iomanip.h>
int main()
{
int a=123;
double b=123.456;
cout<<setiosflags(ios::uppercase)<<hex;
cout<<a<<endl;
cout<<setprecision(5)<<dec;
cout<<b<<endl;
char str[10];
cout<<setw(20)<<setfill('*');
cout<<"Input a string:"<<endl;
cin>>ws>>str; //格式化输入
cout<<str<<endl;
return 0;
}
/*
7B
123.46
*****Input a string:
Do a test.
Do
Press any key to continue
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -