Advertisement
hmcristovao

Lista 05 - exerc 06

Jul 3rd, 2013
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.   int m[10][10];
  4.   int l,c;
  5.   srand(time(NULL));
  6.   // preenchimento da matriz com números aleatório de 1 a 9
  7.   for(l=0; l<10; l++)
  8.      for(c=0; c<10; c++)
  9.         m[l][c] = rand()%9 + 1;
  10.  
  11.   // exibição dos valores da matriz, formato convencional
  12.   for(l=0; l<10; l++)
  13.      for(c=0; c<10; c++)
  14.         printf("m[%1d][%1d] = %1d\n",l+1,c+1,m[l][c]);
  15.  
  16.   // exibição dos valores da matriz, formato matricial
  17.   printf("\n\n");
  18.   for(l=0; l<10; l++) {
  19.      for(c=0; c<10; c++)
  20.         printf("%1d  ",m[l][c]);
  21.      printf("\n");
  22.   }
  23.   return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement