第23039题 单选题
判断彩球颜色的C++代码片段的正确说法是?

有数量无限的红(Red)绿(Green)蓝(Blue)三种彩球排成一行,每组先为5个红色球,随后3个绿色,最后为2个蓝色。每个球都有编号,从左到右依次为1,2,3……。输入整数代表编号,求该编号球的颜色。下面是实现的C++代码片段:

int N, remainder;
cin >> N;
remainder = N % 10; // remainder变量保存余数
if((1 <= remainder) && (remainder<= 5))
    cout << "Red";
else if ((6 <= remainder) && (remainder <= 8))
    cout << "Green";
else if ((remainder == 9) || (remainder == 0))
    cout << "Blue";
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析