#include <iostream>
#using namespace std;
void leerMatriz(int M[3][3]);
void printMatriz(int M[3][3]);
void elementoRepetido(int M1[3][3], int M2[3][3], int M3[3][3]);
int main(){
int A[3][3], B[3][3]), C[3][3])
cout<<"Leer la matriz A: "<<endl;
leerMatriz(A);
cout<<"Leer la matriz B: "<<endl;
leerMatriz(B);
cout<<"Leer la matriz C: "<<endl;
leerMatriz(C);
printMatriz(A);
cout<<endl;
printMatriz(B);
cout<<endl;
printMatriz(C);
cout<<endl;
elementoRepetido(A, B, C);
return 0;
}
void leerMatriz(int M[3][3])
{
for(int i=0; i<3; i++)
for(int j=0; j<3; j++)
cin>>M[i][j];
}
void printMatriz(int M[3][3])
{
for(int i=0; i<3; i++){
for(int j=0; j<3; j++)
cin<<M[i][j]<<" ";
cout<<endl;
}
}
void elementoRepetido(int M1[3][3], int M2[3][3], int M3[3][3])
{
int c=0, ct=0, temp=0, M[3][9];
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
if(j<3)
M[i][j] = M1[i][j];
else if(j<6)
M[i][j] = M2[i][j-3];
else
M[i][j] = M3[i][j-6];
}
}
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
for(int it=0; it<3; it++){
for(int jt=0; jt<3; jt++){
if(M[i][j]==M[it][jt])
c++;
}
}
if(c>ct){
ct = c;
temp = M[i][j];
}
c=0;
}
}
cout<<temp<<" se repite "<<ct<<" veces";
}