横式与竖式计算程序
// 横式与竖式#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int x, y;
cout << "请输入 x :";
cin >> x;
cout << "请输入 y :";
cin >> y;
cout << endl;
cout << x << " + " << y << " = " << x + y << endl;
cout << setw(20) << right << x << endl;
cout << "+";
cout << setw(19) << right << y << endl;
cout << setfill('-') << setw(20) << "" << endl;
cout << setfill(' ') << setw(20) << right << x + y << endl;
return 0;
}
执行结果:
请输入 x :123456
请输入 y :612345
123456 + 612345 = 735801
123456
+ 612345
--------------------
735801
页:
[1]