#1442. 珅泽教育CSP-J第一轮模拟考第一套 第 16 题

珅泽教育CSP-J第一轮模拟考第一套 第 16 题

阅读程序(第 1 篇)

#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    int s = 0;
    int c = 0;
    while (a > 0 || b > 0)
    {
        int x = a % 10;
        int y = b % 10;
        a /= 10;
        b /= 10;
        if (x + y + c >= 10)
        {
            c = 1;
            s++;
        }
        else
        {
            c = 0;
        }
    }
    std::cout << s << "\n";
}

当输入为 1 1 时,程序的输出 2

{{ select(1) }}

  • 正确
  • 错误