c语言:在n行n列(n<=10)的二维整数数组中,按照以下要求选出一个数。首先从每行中选出最大数,再从选出的n个最大数中选出最小数 程序运行示例: Please enter the order of the matrix:3 Please input the elements of the matrix: 9 2 3 4 5 8 7 2 1 The minimum of maximum number is 7. 输入提示:“PIease enter the order of the matrix:” 输入格式:%d 输入提示:“please input the elements of the matrix:\n” 输入格式:%d 输出提示:“The minimum of maximum number is %d.\n”
时间: 2024-02-24 22:56:56 浏览: 27
以下是实现该功能的 C 语言代码:
```c
#include <stdio.h>
int main() {
int n, max, minMax;
int matrix[10][10];
printf("Please enter the order of the matrix:");
scanf("%d", &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]);
}
}
minMax = matrix[0][0];
for (int i = 0; i < n; i++) {
max = matrix[i][0];
for (int j = 1; j < n; j++) {
if (matrix[i][j] > max) {
max = matrix[i][j];
}
}
if (max < minMax) {
minMax = max;
}
}
printf("The minimum of maximum number is %d.\n", minMax);
return 0;
}
```
程序的实现思路是:先读入矩阵的大小和元素,然后遍历每一行,找出每一行的最大值,并记录下最小的最大值。最后输出记录的最小最大值即可。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)