From 771882a2c87084613b64c4622caa53dfc2deede1 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 1 Jun 2020 20:43:27 +0200 Subject: =?UTF-8?q?Resuelto=20151=20en=20c++:=20=C2=BFEs=20matriz=20identi?= =?UTF-8?q?dad=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c/151_esMatrizIdentidad.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 c/151_esMatrizIdentidad.cpp diff --git a/c/151_esMatrizIdentidad.cpp b/c/151_esMatrizIdentidad.cpp new file mode 100644 index 0000000..ba6dd34 --- /dev/null +++ b/c/151_esMatrizIdentidad.cpp @@ -0,0 +1,28 @@ +#include + +void solveMatrix(int size) { + int value; + int wrong = 0; + for (int row = 0; row < size; row++) { + for (int col = 0; col < size; col++) { + std::cin >> value; + if ( (col == row && value != 1) || (col != row && value != 0) ) { + wrong = 1; + } + } + } + if (wrong) + std::cout << "NO\n"; + else + std::cout << "SI\n"; +} + +int main() { + int size; + std::cin >> size; + while (size != 0) { + solveMatrix(size); + std::cin >> size; + } + return 0; +} -- cgit v1.2.1