我想問一下,怎么樣可以輸出兩個并排的表格呀,程式設計第五章第五題
uj5u.com熱心網友回復:
#include <iostream>#include <iomanip>
using namespace std;
int main()
{
const double KILOGRAMS_TO_POUNDS = 2.2;
cout << left;//設定輸出左對齊
cout << setw(10) << "Kilograms" << "\t" << "Pounds" << "\t|" << "\t" << "Pounds\t" << "Kilograms" << endl;
for (int i = 1; i < 200; i += 2)
{
cout << left;
cout << setw(10) << fixed << setprecision(2) << i << "\t" << i * KILOGRAMS_TO_POUNDS << "\t|"
<< "\t" << i * 2.5 + 17.5 << "\t" << (i * 2.5 + 17.5) / KILOGRAMS_TO_POUNDS << endl;
}
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/251846.html
標籤:C++ 語言
