program.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. @target mips, mipt2
  2. package main;
  3. const (
  4. LIN = 5
  5. COL = 5
  6. )
  7. var (
  8. origin [LIN][COL]int
  9. result [LIN][COL]int
  10. )
  11. func preenche_matriz() {
  12. var (
  13. w = 1
  14. value int
  15. )
  16. LM1 := LIN - 1
  17. CM1 := COL - 1
  18. for i := 0; i < LIN; i++ {
  19. for j := 0; j < COL; j++ {
  20. switch {
  21. case i == 0, i == LM1: // Primeira e ultima linha
  22. value = 0
  23. case j == 0, j == CM1: // Primeira e ultima coluna
  24. value = 0
  25. default: // Elementos do interior da matriz
  26. value = w
  27. w++
  28. }
  29. origin[i][j] = value
  30. }
  31. }
  32. }
  33. func laplaciano() {
  34. var (
  35. l int
  36. //LM1,CM1 int
  37. )
  38. LM1 := LIN - 1
  39. CM1 := COL - 1
  40. for i:= 1; i < LM1; i++ {
  41. for j := 1; j < CM1; j++ {
  42. l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
  43. if l > 255 { l = 255 }
  44. result[i][j] = l
  45. }
  46. }
  47. }
  48. func main() {
  49. preenche_matriz()
  50. laplaciano()
  51. }
  52. /*
  53. lab_1:
  54. l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
  55. lab_2:
  56. l = l + origin[i][j-1]
  57. lab_3:
  58. l = l + origin[i][j+1]
  59. lab_4:
  60. l = l + origin[i+1][j]
  61. lab_5:
  62. l = l - (4 * origin[i][j])
  63. lab_6:
  64. */
  65. /**
  66. */
  67. /*
  68. const (
  69. X = 10
  70. Y = 20
  71. )
  72. func main(){
  73. var (
  74. x [Y]int
  75. i = 12
  76. )
  77. //i++
  78. //i += 10
  79. //x[i + 3] = 40
  80. x[X + 3] = i
  81. }
  82. */