测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A22415. #include<bits/stdc++.h> using namespace std; int a[501], b[501], c[501]; string str1, str2; int main() { cin >> str1 >> str2; int al = str1.length(), bl = str2.length(); for (int i = al - 1, j = 1; i…

判断题 较易

题目描述

#include<bits/stdc++.h>
using namespace std;
int a[501], b[501], c[501];
string str1, str2;
int main() {
    cin >> str1 >> str2;
    int al = str1.length(), bl = str2.length();
    for (int i = al - 1, j = 1; i >= 0; i--, j++) {
        a[j] = str1[i] - '0';
    }
    for (int i = bl - 1, j = 1; i >= 0; i--, j++) {
        b[j] = str2[i] - '0';
    }
    int l = max(al, bl);
    for (int i = 1; i <= l; i++) {
        c[i] += a[i] + b[i];
        c[i + 1] += c[i] / 10;
        c[i] %= 10;
    }
    if (c[l + 1] != 0) {
        l++;
    }
    for (int i = l; i >= 1; i--) {
        cout << c[i];
    }
    return 0;
    }
    假设输入的str1, str2都是由不超过500位整数字符组成的字符串,完成下面的判断题和单选题:

去掉程序的第20、21、22行,不影响程序运行的结果。(    )

选项(单选)

上一题 下一题