鱼C论坛

 找回密码
 立即注册
查看: 2387|回复: 0

[技术交流] 横式与竖式计算程序

[复制链接]
发表于 2020-1-6 20:29:25 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. // 横式与竖式

  2. #include <iostream>
  3. #include <iomanip>

  4. using namespace std;

  5. int main() {
  6.         int x, y;
  7.         cout << "请输入 x :";
  8.         cin >> x;
  9.         cout << "请输入 y :";
  10.         cin >> y;
  11.         cout << endl;
  12.         cout << x << " + " << y << " = " << x + y << endl;
  13.         cout << setw(20) << right << x << endl;
  14.         cout << "+";
  15.         cout << setw(19) << right << y << endl;
  16.         cout << setfill('-') << setw(20) << "" << endl;
  17.         cout << setfill(' ') << setw(20) << right << x + y << endl;
  18.         return 0;
  19. }
复制代码


执行结果:

  1. 请输入 x :123456
  2. 请输入 y :612345

  3. 123456 + 612345 = 735801
  4.               123456
  5. +             612345
  6. --------------------
  7.               735801
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-7 11:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表