Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Luciana ( 15 years ago )
#include <stdio.h>
#include <conio.h>

#define alt 6
#define larg 6
#define quad 3

main(){
  int x, y, i, j, soma=0;
  int imagem[alt][larg], indice[quad][quad], New[alt][larg];
  
  // Inicializações de matrizes ------------------------------------------------
  
  for(y=0; y<alt; y++){
    for(x=0; x<larg; x++){
      imagem[x][y] = x + 1;
      New[x][y] = 0;         
    }
  }       

  for(y=0; y<quad; y++){
    for(x=0; x<quad; x++){
      indice[x][y] = 1;
      soma = soma + indice[x][y];
    }
  }  
  printf("SOMA: %i\n\n", soma);     
// -----------------------------------------------------------------------------

  // Visualização de matrizes; -------------------------------------------------
  puts("Matriz: New\n\n");  
  for(y=0; y<alt; y++){
    for(x=0; x<larg; x++){
      printf(" %i ", New[x][y]);
    }
    puts("\n");
  }       
  puts("\n\n");

  puts("Matriz: imagem\n\n");  
  for(y=0; y<alt; y++){
    for(x=0; x<larg; x++){
      printf(" %i ", imagem[x][y]);
    }
    puts("\n");
  }       
  puts("\n\n");
  
  puts("Matriz: indice\n\n");
  for(y=0; y<quad; y++){
    for(x=0; x<quad; x++){
      printf(" %i ", indice[x][y]);
    }
    puts("\n");
  }       
// -----------------------------------------------------------------------------

// Algoritmo; ------------------------------------------------------------------

  for(x=1; x<alt; x++){
    for(y=1; y<larg; y++){
      if(x<alt-1 && y<larg-1){
        for(i=-1; i<2; i++){
          for(j=-1; j<2; j++){
            printf("Indice: %i   ", indice[i][j]);
            //printf("Imagem: %i   ", imagem[x+i][y+j]);
            //printf("New: %i   \n", New[x][y]);
            New[x][y] = New[x][y] + indice[i][j]* imagem[x+i][y+j];
          } 
          puts("\n");         
        }           
      }
      puts("\n");
    }         
  }

// -----------------------------------------------------------------------------

  getch();
}

 

Revise this Paste

Your Name: Code Language: