program.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. lab_1:
  43. l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
  44. /*
  45. lab_2:
  46. l = l + origin[i][j-1]
  47. lab_3:
  48. l = l + origin[i][j+1]
  49. lab_4:
  50. l = l + origin[i+1][j]
  51. lab_5:
  52. l = l - (4 * origin[i][j])
  53. lab_6:
  54. */
  55. if l > 255 {
  56. l = 255
  57. }
  58. result[i][j] = l
  59. }
  60. }
  61. }
  62. /*
  63. */
  64. func main() {
  65. preenche_matriz()
  66. laplaciano()
  67. }
  68. /**
  69. */
  70. /*
  71. const (
  72. X = 10
  73. Y = 20
  74. )
  75. func main(){
  76. var (
  77. x [Y]int
  78. i = 12
  79. )
  80. //i++
  81. //i += 10
  82. //x[i + 3] = 40
  83. x[X + 3] = i
  84. }
  85. */