nikolas_serafini

Lista 5 - Exercício 9

Jul 6th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6.   int i,j,lines,columns,begin,end,matrix[10][15];  
  7.  
  8.   srand(time(NULL));
  9.  
  10.   printf("Entre com a quantidade de linhas e colunas para a matriz, respectivamente :\n");
  11.   scanf("%d %d",&lines,&columns);
  12.   printf("Entre com o intervalo numerico para o sorteio (menor e maior, respectivamente :)\n");
  13.   scanf("%d %d",&begin,&end);
  14.  
  15.   for (i = 0; i < lines; i++) {
  16.     for (j = 0; j < columns; j++)
  17.         matrix[i][j] = rand() % begin + (end - begin + 1);
  18.   }
  19.    
  20.   for (i = 0; i < lines; i++) {
  21.     for (j = 0; j < columns; j++) {
  22.       printf("%d ",matrix[i][j]);
  23.     }
  24.     printf("\n");
  25.   }
  26.      
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment