单选题 适中
#20306

以下程序使用枚举法(穷举法)求解满足条件的三位数,横线处应该填入的是?( ) # include <iostream> using namespace std…

以下程序使用枚举法(穷举法)求解满足条件的三位数,横线处应该填入的是?( )

#include <iostream>
using namespace std;
int main() {
    int count = 0;
    for (int i = 100; i <= 999; i++) {
        int a = i / 100;
        ______________________
        int c = i % 10;
        if (a * a + b * b == c * c) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}
未登录也能判分,登录后才会记录
答案与解析
正确答案:B
解析

由前后的代码可知,a是百位数,c是个位数,则横线处是变量b为i的十位数。

十位数使用:i / 10 % 10,即选项B。