Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- /* 9. Preencha uma matriz com números aleatórios (inteiros). Para isto solicite ao usuário quantas
- linhas e colunas a matriz possui, e a faixa de números que devem ser sorteados.
- Exiba todo o conteúdo da matriz de forma organizada, por exemplo, uma matriz de 3 linhas e 6
- colunas com números sorteados entre 1000 e 3000, seria exibida desta forma:
- 1003 1569 1789 1110 2000 1212
- 1103 1662 1989 1200 2406 1819
- 1045 1749 1980 1310 2507 1815 */
- int main()
- {
- int quantLinhas,quantColunas,i,j,limiteInferior,LimiteSuperior;
- printf("\n Digite a quantidade de Linhas e coluna da matriz: ");
- scanf("%d %d",&quantLinhas,&quantColunas);
- printf("\n Digite o limite inferior e superior do sorteio: ");
- scanf("%d %d",&limiteInferior,&LimiteSuperior);
- int matriz[quantLinhas][quantColunas];
- for(i=0;i<quantLinhas;i++)
- {
- for(j=0;j<quantColunas;j++)
- {
- matriz[i][j]=(rand()%(LimiteSuperior-limiteInferior+1))+limiteInferior;
- printf("%d ",matriz[i][j]);
- }
- printf("\n");
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement