1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- @target mips, mipt2
- package main;
- const (
- LIN = 5
- COL = 5
- )
- var (
- origin [LIN][COL]int
- result [LIN][COL]int
- )
- func preenche_matriz() {
- var (
- w = 1
- value int
- )
-
- LM1 := LIN - 1
- CM1 := COL - 1
- for i := 0; i < LIN; i++ {
- for j := 0; j < COL; j++ {
- switch {
- case i == 0, i == LM1: // Primeira e ultima linha
- value = 0
- case j == 0, j == CM1: // Primeira e ultima coluna
- value = 0
- default: // Elementos do interior da matriz
- value = w
- w++
- }
- origin[i][j] = value
- }
- }
- }
- func laplaciano() {
- var (
- l int
- //LM1,CM1 int
-
- )
- LM1 := LIN - 1
- CM1 := COL - 1
- for i:= 1; i < LM1; i++ {
- for j := 1; j < CM1; j++ {
- l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
- if l > 255 { l = 255 }
- result[i][j] = l
- }
- }
- }
- func main() {
- preenche_matriz()
- laplaciano()
- }
- /*
- lab_1:
- l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
- lab_2:
- l = l + origin[i][j-1]
- lab_3:
- l = l + origin[i][j+1]
- lab_4:
- l = l + origin[i+1][j]
- lab_5:
- l = l - (4 * origin[i][j])
- lab_6:
- */
- /**
- */
- /*
- const (
- X = 10
- Y = 20
- )
- func main(){
- var (
- x [Y]int
- i = 12
- )
- //i++
- //i += 10
- //x[i + 3] = 40
- x[X + 3] = i
- }
- */
|