Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdio_ext.h>
- void pause(){
- __fpurge(stdin);
- getchar();
- }
- int main(){
- int teste; // Vatiável de teste
- int matriz[20][20];
- // Cria tabela 20x20 randômica
- for (int a = 0; a < 20; a++){
- for (int b = 0; b < 20; b++){
- printf("%d\t", matriz[a][b] = rand()%99); // Cria um número randômico pra cada posição da matriz
- if ((a == 0) && (b == 0)) teste = matriz[0][0]; // Testando pq o valor da primeira posição (0,0) muda
- //pause();
- if (b == 19) printf("\n");
- }
- }
- printf("\n\n0,0 %d\n0,1 %d\n0,2 %d\n\n\nteste %d\n----\n",matriz[0][0],matriz[0][1],matriz[0][2],teste);
- int contH = 0, contV = 0, contD = 0, cont = 0, produto[396];
- for (int j = 0; j < 397; j++) produto[j] = 1; // Inicia variéveis do 0 ao 396
- // Verifica na horizontal
- for (int a = 0; a < 20; a++){
- for (int b = 0; b < 20; b++){
- cont++;
- produto[contH] *= matriz[a][b];
- //printf("%d\t", matriz[a][b]);
- if (cont == 4){
- //printf("\t%d- %d\n",contH,produto[contH]);
- cont = 0;
- contH++;
- b -= 3;
- }
- }
- }
- //printf("\n\n%d\n\n",contH);
- printf("\n\n0,0 %d\n0,1 %d\n0,2 %d\n\n\nteste %d\n----\n",matriz[0][0],matriz[0][1],matriz[0][2],teste);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement