Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- int main()
- {
- int i,j,begin,end,par = 0, impar = 0,matrix[8][20];
- srand(time(NULL));
- input:
- printf("Insira o intervalo desejado :\n");
- scanf("%d %d",&begin,&end);
- if (begin > end)
- goto input;
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < 20; j++)
- {
- matrix[i][j] = rand() % (end-begin+1) + begin;
- printf("%d ",matrix[i][j]);
- if (matrix[i][j] % 2 == 0)
- par++;
- else
- impar++;
- }
- printf("\n");
- }
- printf("\nQuantidade de numeros pares : %d\nPorcentagem de pares : %.3f\nQuantidade de numeros impares : %d\nPorcentagem de impares : %.3f\n",par,(float)par/160*100,impar,(float)impar/160*100);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment