12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #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;
- }
- // 找到每行的最小值
- 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];
- }
- }
- }
- 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];
- }
- }
- }
- 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);
- }
- }
- }
- }
- 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]);
- }
- }
- // 查找二维数组的最小点
- find_minimum_points(matrix, n, m);
- return 0;
- }
|