Código:
#include <iostream> #define KFila 1 #define KCol 1 using namespace std; bool atacan (int reina1[][KCol], int reina2[][KCol], int x1, int x2, int y1, int y2) { bool si=false; if (reina1[KFila][KCol]==reina2[KFila][KCol]) // misma fila si=true; else if (reina1[KFila][KCol+1]==reina2[KFila][KCol+1]) // misma columna si=true; else if (reina1[KFila+1][KCol+1]==reina2[KFila+1][KCol+1]) si=true; return si; } main() { int reina1[KFila][KCol]; int reina2[KFila][KCol]; int x1, x2, y1, y2; cout << "Parametros reina 1; "; cin >> reina1[KFila][KCol]; cin >> reina1[KFila][KCol+1]; cout << "Parametros reina 2; "; cin >> reina2[KFila][KCol]; cin >> reina2[KFila][KCol+1]; if (atacan(reina1, reina2, x1, x2, y1, y2)) cout << "Se atacan" << endl; else cout << "No se atacan" << endl; }