Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 4
- void Diagonales (char A[N][N]);
- int main(void)
- {
- char matrix[N][N]=
- {
- {'a','b','c','d'},
- {'e','f','g','h'},
- {'i','j','k','l'},
- {'m','n','o','p'}};
- Diagonales(matrix);
- return 0;
- }
- void Diagonales (char A[N][N]){
- int count = N - 1;
- int i = 0, j = count;
- while (count >= 0){ //Triángulo superior de la matriz y diagonal principal
- while ((j < N) && (i < N)){
- printf("%c", A[i][j]);
- ++j;
- ++i;
- }
- printf("\n");
- --count;
- j = count;
- i = 0;
- }
- j = 0;
- i = count = 1;
- while (count < N){ //Triángulo inferior de la matriz
- while ((j < N) && (i < N)){
- printf("%c", A[i][j]);
- ++i;
- ++j;
- }
- printf("\n");
- ++count;
- i = count;
- j = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement