const int N = 100; int getcolnum(int A[N][N], int n, int rowsubscript, int columnsubscript);
int main() { int A[N][N]; int n; for ( int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { A[i][j] = 0; } } scanf("%d", &n); for (int i = 0; i < n; i++ ) { for (int j = 0; j < n; j++) { scanf("%d", &A[i][j]); } } int rowsubscript, columnsubscript, check; check = 0; for ( int i = 0; i < n; i++) { //初始化行列号,仅判断一行中的大小。 rowsubscript = i; columnsubscript = 0; for (int j = 0; j < n; j++) { if ( A[i][j] > A[rowsubscript][columnsubscript]) { rowsubscript = i; columnsubscript = j; } } if (getcolnum(A, n, rowsubscript, columnsubscript)) { check = 1; break; //符合条件立即跳出循环,防止行列号被循环改变 } } if (check == 1 ) { printf("%d %d", rowsubscript, columnsubscript); } else { printf("NO"); } return 0; }
int getcolnum(int A[N][N], int n, int rowsubscript, int columnsubscript) { int check = 1; for ( int i = 0; i < n; i++) { if (A[i][columnsubscript] < A[rowsubscript][columnsubscript]) { check = 0; } } return check; }