输入两个整数a,b
输出格式:
a,b占据6个字符宽度,靠右、左对齐分别输出两次
方法一
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
printf("%6d%6d",a,b);//靠右对齐
cout<<endl;
printf("%-6d%-6d",a,b);//靠左对其
return 0;
}
方法二
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<std::right<<setw(6)<<a<<std::right<<setw(6)<<b<<endl;//靠右对齐
cout<<std::left<<setw(6)<<a<<std::left<<setw(6)<<b<<endl;//靠左对其
return 0;
}