#include using namespace std;

int birdColors[10]; // 声明全局变量,用于存储冰鸟的颜色编号

int main() { for (int i = 0; i < 10; i++) { cin >> birdColors[i]; // 输入冰鸟的颜色编号 } int targetColor; cin >> targetColor; // 输入目标颜色编号

int count = 0; // 计数器,用于统计闪烁着翡翠色光芒的冰鸟数量

for (int i = 0; i < 10; i++) {
    if (birdColors[i] == targetColor) {
        count++; // 如果冰鸟的颜色编号与目标颜色编号相同,则计数器加1
    }
}

cout << count << endl; // 输出闪烁着翡翠色光芒的冰鸟数量

return 0;

}

c++使用全局变量天上飞过去10只冰鸟每只冰鸟都有自己的颜色编号。小核桃想知道闪烁着翡翠色光芒的冰鸟的数量请你编写程序帮他计算吧。输入 共两行。第一行为十个整数每个整数表示一只飞过的冰鸟的颜色编号保证每个编号都小于等于10。第二行为一个整数k表示闪烁着翡翠色光芒的冰鸟的颜色编号。输出 一个整数表示闪烁着翡翠色光芒的冰鸟的数量。输入样例1 3 1 4 1 5 9 2 6 5 35输出样例1 2输入样

原文地址: https://www.cveoy.top/t/topic/ifRd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录