c++输出对齐问题
#include<iostream>
#include<iomanip>
using?namespace?std;
void?main()
{
????cout<<std::left<<setw(20)<<"商品名"<<std::right<<setw(6)<<"金額"<<endl;
????cout<<std::left<<setw(20)<<"蘋果"<<std::right<<setw(6)<<123<<endl;
????cout<<std::left<<setw(20)<<"香蕉橘子"<<std::right<<setw(6)<<1456<<endl;
}
//setw(20)??表明輸出的寬度???std::left左對齊???std::right右對齊
與50位技術專家面對面20年技術見證,附贈技術全景圖
與50位技術專家面對面20年技術見證,附贈技術全景圖
總結
- 上一篇: 小程序爬坑
- 下一篇: c/c++的输入输出总结