代码练习
代码
#include <iostream>
#include <iomanip>
#include <cmath>
#include <windows.h>
using namespace std;
int main()
{
SetConsoleTitle("心情不好乱写的垃圾代码");
double attack1 = 264;
double attack2 = 280;
double attack3 = 295;
cout<<left;
cout<<setfill('*');
cout<<setw(8)<<attack1<<
setw(8)<<attack2<<
setw(8)<<attack3<<endl;
cout<<right;
cout<<setfill('^');
cout<<setw(8)<<attack1<<
setw(8)<<attack2<<
setw(8)<<attack3<<endl;
cout<<(char)('R'+' ')<<endl;
string str = "未见秋意";
cout<<str<<endl;
cout<<"\a"<<endl;
cout<<(char)('A'+' ')<<endl;
cout<<CHAR_MAX<<endl<<CHAR_MIN<<endl<<UCHAR_MAX<<endl;
cout<<sizeof(long double)<<endl;
return 0;
}
运行截图
总结
1.cout<<setfill(‘a’)以a填充;
2.设置宽度左对齐时,用cout<<left;右对齐时用cout<<right;