本帖最后由 jackz007 于 2024-11-14 23:54 编辑 #include <stdio.h>
#define MAX 256
int main(void)
{
int c , d[MAX][MAX] , e , f , i , j , k , r ;
printf("input c and r : ") ;
scanf("%d%d" , & c , & r) ;
for(i = 0 ; i < r ; i ++) {
printf("input the elements for column %d : " , i + 1) ;
for(j = 0 ; j < r ; j ++) scanf("%d" , & d[i][j]) ;
}
for(f = i = 0 ; ! f && i < c ; i ++) {
for(k = 0 , j = 1 ; j < r ; j ++) if(d[i][j] > d[i][k]) k = j ;
for(e = 0 , j = 0 ; j < r ; j ++) if(d[i][j] == d[i][k]) e ++ ;
if(e == 1) {
for(j = 0 ; j < c ; j ++) if(j != i && d[j][k] <= d[i][k]) break ;
if(j == c) {
printf("the element [%d][%d] = %d\n" , i , k , d[i][k]) ;
f = 1 ;
}
}
}
if(! f) printf("not found !\n") ;
}
编译、运行实况:D:\[exercise]\C>g++ -static -o x x.c
D:\[exercise]\C>x
input c and r : 3 3
input the elements for column 1 : 66 76 99
input the elements for column 2 : 33 24 88
input the elements for column 3 : 10 36 52
the element [2][2] = 52
D:\[exercise]\C>
|