用c语言实现在n行n列(n<=10) 的二维整数组中,按照以下要求选出一个数,首先从每行中选出最大数,再从选出的n个最大数中选出最小数
时间: 2024-02-17 09:59:41 浏览: 203
C语言输入一个整数序列并计算他们的值.rar_C语言输入一个整数序列并计算他们的值_输入序列C语言
5星 · 资源好评率100%
好的,以下是用 C 语言实现的代码:
```c
#include <stdio.h>
int main() {
int n;
printf("Please enter the order of the matrix (n <= 10): ");
scanf("%d", &n);
int matrix[n][n];
printf("Please input the elements of the matrix:\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
scanf("%d", &matrix[i][j]);
}
}
int max[n], min_max;
for (int i = 0; i < n; i++) {
max[i] = matrix[i][0];
for (int j = 1; j < n; j++) {
if (matrix[i][j] > max[i]) {
max[i] = matrix[i][j];
}
}
}
min_max = max[0];
for (int i = 1; i < n; i++) {
if (max[i] < min_max) {
min_max = max[i];
}
}
printf("The minimum of maxima number is %d.\n", min_max);
return 0;
}
```
运行结果示例:
```
Please enter the order of the matrix (n <= 10): 3
Please input the elements of the matrix:
9 2 3
4 5 8
7 7 1
The minimum of maxima number is 7.
```
希望能够帮到您!
阅读全文