Está en la página 1de 2

Puntodesillacpp.

txt
#include <iostream>
using namespace std;

int const M = 3;
int const N = 3;
typedef int Matriz[M][N];
void leerMatriz(Matriz v){
for (int i=0;i<M;i++){
cout << "Escribe la fila " << i+1 << ": ";
for(int j=0;j<N;j++){
cin >> v[j][i];
}
}
}
bool esMenor(Matriz v,int fila, int & posMenor,int & menorF){
int contador = 0;
menorF = v[0][fila];
posMenor = 0;
for(int j=1;j<N;j++){
if (v[j][fila] < menorF){
menorF = v[j][fila];
posMenor = j;
}
}
for(int j=0;j<N;j++){
if((menorF == v[j][fila]) && (j != posMenor)){
return false;
}
}
return true;
}
bool esMayor(Matriz v,int col, int & menorF, int & mayorC,int filaActual){
int contador = 0;
mayorC = menorF;
for(int j=0;j<N;j++){
if (j != filaActual){
if (v[col][j] < mayorC){
}else if (v[col][j] == mayorC){
contador++;
}else{
contador++;
}
}
}
if (contador > 0){
return false;
}else{
return true;
}
}
int main(){
Matriz v;
leerMatriz(v);
double mayorColumna;
int posMenorF;
int menorF;
int mayorC;
int posMayorC;
int contador = 0;

for(int j=0;j<N;j++){
if(esMenor(v,j,posMenorF,menorF)){
if(esMayor(v,posMenorF,menorF,mayorC,j)){
Página 1
Puntodesillacpp.txt
cout << "El punto de silla es: " << mayorC << " en la posicion:
" << "( " << j+1 << "," << posMenorF+1 << " )" << endl;
contador++;
}
}
}
if (contador == 0){
cout << "***No hay punto de silla***" << endl;
}
system("pause");
return 0;
}
/*-------------------------------------------------------------------------

Escribe la fila 1: 2 1 2
Escribe la fila 2: 2 0 3
Escribe la fila 3: 1 0 6
El punto de silla es: 1 en la posicion: ( 1,2 )
Presione una tecla para continuar . . .
Escribe la fila 1: 1 1 2
Escribe la fila 2: 2 1 1
Escribe la fila 3: 2 1 2
***No hay punto de silla***
Presione una tecla para continuar . . .
-------------------------------------------------------------------------*/

Página 2

También podría gustarte