Advertisement
F_THIAGO

Matrizes - Questão 1

Feb 13th, 2019
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /*
  4. * Preencher uma matriz 3x3 e imprimir
  5. */
  6.  
  7. int main( void )
  8. {
  9.     // Cria as variaveis usadas
  10.     int matriz[3][3];
  11.     int linhas, colunas;
  12.    
  13.     // Preenche a matriz pelo teclado
  14.     for( linhas=0; linhas<3; linhas++ )
  15.     {
  16.         for( colunas=0; colunas<3; colunas++ )
  17.         {
  18.             printf("Elemento [%d][%d]: ", linhas, colunas);
  19.             scanf("%d", &matriz[linhas][colunas]);
  20.         }
  21.     }
  22.    
  23.     // Exibe a matriz
  24.     printf("\n");
  25.     for( linhas=0; linhas<3; linhas++ )
  26.     {
  27.         for( colunas=0; colunas<3; colunas++ )
  28.              printf("%d ", matriz[linhas][colunas]);
  29.              
  30.         printf("\n");
  31.     }
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement