C++ 编写程序判断飞船传感器雷达检测结果
#include "iostream"\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n int count = 0; // 计数器,记录偶数的个数\n for (int i = 0; i < n; i++) {\n int result;\n cin >> result;\n if (result % 2 == 0) { // 判断是否为偶数\n count++;\n }\n }\n if (count == n) { // 如果偶数的个数等于传感器的个数,则输出"Yes"\n cout << "Yes" << endl;\n } else {\n cout << "No" << endl;\n }\n return 0;\n}
原文地址: https://www.cveoy.top/t/topic/pXxy 著作权归作者所有。请勿转载和采集!