Advertisement
weldisalves

Lista 05 - exercício 12

Jun 28th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /* 12. Crie a seguinte matriz quadrada. O tamanho da matriz é informado pelo usuário.
  4.  */
  5.  
  6. int main()
  7. {
  8.     int quantLinhas,quantColunas,i,j;
  9.  
  10.     printf("\n Digite a quantidade de linhas e colunas: ");
  11.     scanf("%d %d",&quantLinhas,&quantColunas);
  12.  
  13.     int matriz[quantLinhas][quantColunas];
  14.  
  15.     for(i=0;i<quantLinhas;i++)
  16.     {
  17.         for(j=0;j<quantColunas;j++)
  18.         {
  19.             matriz[i][j]=j+1;
  20.             printf("%2d ",matriz[i][j]);
  21.         }
  22.         printf("\n");
  23.     }
  24.  
  25.  
  26.     getchar();
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement