当前位置:首页 > 83课趣味CPP > 正文

第9课时- 竖式计算(设置域宽setw)

#include<iostream>
#include<iomanip>  //为了使用setw()来设置域宽
using namespace std;
int  main()
{
  int  a,b,s;
  a=18;
  b=870;
  s=a+b;
  cout<<setw(10)<<a<<endl;  
  cout<<setw(4)<<'+'<<setw(6)<<b<<endl; 
  cout<<" -----------"<<endl;
  cout<<setw(10)<<s<<endl; 
  return 0;
 }


更新时间 2025-09-11