Created
November 18, 2016 16:26
-
-
Save jfreites/89141ff4ebface7a7925eeebdfa5b459 to your computer and use it in GitHub Desktop.
Imprimir todas las diagonales de una matriz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($i = 0; $i < $rows; $i++) { | |
for ($j = 0; $j < $cols; $j++) { | |
if ($i == $j) { | |
$res .= $arr[$i][$j].'/n'; | |
} | |
if ($i == ($cols - $j - 1)) { | |
$res .= $arr[$i][$j]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment