某校班级有5×5个座位,输出位置最好的一行座位号的代码
时间: 2023-04-01 11:04:17 浏览: 126
以下是输出位置最好的一行座位号的代码:
```c
#include <stdio.h>
int main() {
int seats[5][5] = {
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20},
{21, 22, 23, 24, 25}
};
int best_row = ;
int best_score = ;
for (int i = ; i < 5; i++) {
int score = ;
for (int j = ; j < 5; j++) {
if (seats[i][j] % 2 == ) {
score++;
}
}
if (score > best_score) {
best_row = i;
best_score = score;
}
}
printf("位置最好的一行座位号为:\n");
for (int j = ; j < 5; j++) {
printf("%d ", seats[best_row][j]);
}
printf("\n");
return ;
}
```
阅读全文