gpsgiraldi

2024_ex_matrizes

May 30th, 2024
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | Source Code | 0 0
  1. /***************************************
  2. Definição de uma matriz
  3. ***************************************/
  4. #include <stdio.h>
  5.  
  6. int main()
  7. {
  8.     int i,j,m,n,aux;
  9. //definição da matriz  
  10.     printf("Quantas linhas terá a matriz?\n");
  11.     scanf("%i",&m);
  12.     printf("... e quantas colunas terá a matriz?\n");
  13.     scanf("%i",&n);
  14.     printf("A matriz terá uma ordem %ix%i \n",m,n);
  15.     int mat[m][n];
  16.        
  17. //entrada
  18.     printf("Insira as entradas desejadas para a matriz \n");
  19.     for(i=0;i<m;i++){
  20.         for(j=0;j<n;j++){
  21.             scanf("%i",&mat[i][j]);
  22.         }
  23.     }
  24. //saída
  25.     for(i=0;i<m;i++){
  26.         for(j=0;j<n;j++){
  27.             printf("%i ",mat[i][j]);
  28.         }
  29.     printf("\n");
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment