Advertisement
Guest User

erro

a guest
Mar 19th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdio_ext.h>
  4.  
  5. void pause(){
  6.     __fpurge(stdin);
  7.     getchar();
  8. }
  9.  
  10. int main(){
  11.     int teste; // Vatiável de teste
  12.     int matriz[20][20];
  13.    
  14.     // Cria tabela 20x20 randômica
  15.     for (int a = 0; a < 20; a++){
  16.         for (int b = 0; b < 20; b++){
  17.             printf("%d\t", matriz[a][b] = rand()%99); // Cria um número randômico pra cada posição da matriz
  18.             if ((a == 0) && (b == 0)) teste = matriz[0][0]; // Testando pq o valor da primeira posição (0,0) muda
  19.             //pause();
  20.             if (b == 19) printf("\n");
  21.         }
  22.     }
  23.  
  24.     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);
  25.    
  26.     int contH = 0, contV = 0, contD = 0, cont = 0, produto[396];
  27.     for (int j = 0; j < 397; j++) produto[j] = 1; // Inicia variéveis do 0 ao 396
  28.  
  29.     // Verifica na horizontal
  30.     for (int a = 0; a < 20; a++){
  31.         for (int b = 0; b < 20; b++){
  32.             cont++;
  33.             produto[contH] *= matriz[a][b];
  34.             //printf("%d\t", matriz[a][b]);
  35.             if (cont == 4){
  36.                 //printf("\t%d- %d\n",contH,produto[contH]);
  37.                 cont = 0;
  38.                 contH++;
  39.                 b -= 3;
  40.             }
  41.         }
  42.     }
  43.  
  44.     //printf("\n\n%d\n\n",contH);
  45.     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);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement