判断时候注意分类清楚
#include <stdio.h>
int main() {
int n, m;
scanf("%d %d", &n, &m);
int a[13]; // 数组大小根据n的最大值13设定
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int I_index = 8; // I题是第9个题,在数组中的索引为8(从0开始)
int I_value = a[I_index];
// 条件1:检查通过人数是否达到全场人数的80%
int condition1 = (I_value >= 0.8 * m);
// 条件2:检查严格大于I题通过人数的题目数量是否不超过2个
int count_greater = 0;
for (int i = 0; i < n; i++) {
if (a[i] > I_value) {
count_greater++;
}
}
int condition2 = (count_greater <= 2);
// 满足任一条件则输出"Yes",否则输出"No"
if (condition1 || condition2) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}

京公网安备 11010502036488号