|
@@ -1,58 +1,49 @@
|
|
|
#include <stdio.h>
|
|
|
|
|
|
-void find_minimum_points(int matrix[][10], int n, int m) {
|
|
|
- int min_in_row[n], min_in_col[m];
|
|
|
- int i,j;
|
|
|
-
|
|
|
- // 初始化最小值数组为最大整数
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
- min_in_row[i] = 2147483647;
|
|
|
- }
|
|
|
- for (j = 0; j < m; ++j) {
|
|
|
- min_in_col[j] = 2147483647;
|
|
|
- }
|
|
|
+int main() {
|
|
|
+ int n, m;
|
|
|
+ int i,j;
|
|
|
+ scanf("%d %d", &n, &m);
|
|
|
|
|
|
- // 找到每行的最小值
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
- for (j = 0; j < m; ++j) {
|
|
|
- if (matrix[i][j] < min_in_row[i]) {
|
|
|
- min_in_row[i] = matrix[i][j];
|
|
|
- }
|
|
|
+ int arr[10][10];
|
|
|
+
|
|
|
+ // 读取二维数组元素
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
+ for (j = 0; j < m; j++) {
|
|
|
+ scanf("%d", &arr[i][j]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (j = 0; j < m; ++j) {
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
- if (matrix[i][j] < min_in_col[j]) {
|
|
|
- min_in_col[j] = matrix[i][j];
|
|
|
+ // 查找每行最小值和每列最小值
|
|
|
+ int row_min[10] = {0};
|
|
|
+ int col_min[10] = {0};
|
|
|
+
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
+ row_min[i] = arr[i][0]; // 初始化为第一列的值
|
|
|
+ for (j = 1; j < m; j++) {
|
|
|
+ if (arr[i][j] < row_min[i]) {
|
|
|
+ row_min[i] = arr[i][j];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
- for (j = 0; j < m; ++j) {
|
|
|
- if (matrix[i][j] == min_in_row[i] && matrix[i][j] == min_in_col[j]) {
|
|
|
- printf("%d %d %d\n", matrix[i][j], i + 1, j + 1);
|
|
|
+
|
|
|
+ for (j = 0; j < m; j++) {
|
|
|
+ col_min[j] = arr[0][j]; // 初始化为第一行的值
|
|
|
+ for (i = 1; i < n; i++) {
|
|
|
+ if (arr[i][j] < col_min[j]) {
|
|
|
+ col_min[j] = arr[i][j];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-int main() {
|
|
|
- int n,m,i,j;
|
|
|
- scanf("%d %d", &n, &m);
|
|
|
|
|
|
- int matrix[10][10];
|
|
|
-
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
- for (j = 0; j < m; ++j) {
|
|
|
- scanf("%d", &matrix[i][j]);
|
|
|
+ // 输出"最小点"
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
+ for (j = 0; j < m; j++) {
|
|
|
+ if (arr[i][j] == row_min[i] && arr[i][j] == col_min[j]) {
|
|
|
+ printf("%d %d %d\n", arr[i][j], i + 1, j + 1); // 注意行列从1开始计数
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 查找二维数组的最小点
|
|
|
- find_minimum_points(matrix, n, m);
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
-
|