第22891题 判断题
下面的C++代码段的变量都是整型,它能用于判断输入的正整数是否为对称数。所谓对称数是指从左到右和从右到左读该数,其值相同。例如,121 和 414 都是对称数,而 123 不是对称数。( )

所谓对称数是指从左到右和从右到左读该数,其值相同。例如,121和414都是对称数,而123不是对称数。

cout << "请输入正整数:";
cin >> n;
old_number = n;
new_number = 0;
while (n != 0) {
    new_number = new_number * 10 + n % 10;
    n /= 10;
}
if (old_number == new_number)
    cout << "对称数";
else
    cout << "非对称数";
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析