program_mult.go 689 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. @target mips, mipt2
  2. package main;
  3. const (
  4. LIN = 2
  5. COL = 2
  6. )
  7. var (
  8. matrizA [LIN][COL]int
  9. matrizB [LIN][COL]int
  10. matrizR [LIN][COL]int
  11. )
  12. func preenche(){
  13. var k = 1
  14. for i := 0; i < LIN ; i++ {
  15. for j := 0; j < COL ; j++ {
  16. matrizA[i][j] = k
  17. matrizB[i][j] = k
  18. k++
  19. }
  20. }
  21. }
  22. func multiplica() {
  23. var aux = 0
  24. for i := 0; i < LIN; i++ {
  25. for j := 0; j < COL; j++ {
  26. for k := 0; k < LIN; k++ {
  27. aux = aux + (matrizA[i][k] * matrizB[k][j])
  28. }
  29. matrizR[i][j] = aux
  30. aux = 0
  31. }
  32. }
  33. }
  34. func main() {
  35. preenche()
  36. multiplica()
  37. }