Matrix 5x5 with Portuguese - Learning to program [closed]

-6

I'm a student and I'm starting to learn about programming, I have an exercise that I could not solve myself and I would like to know if anyone here could help me with the solution and / or an explanation so I can understand this and try to solve others similar to this by myself.

I need an algorithm in Portuguese , which has a 5x5 matrix, where each position represents a city: A, B, C, D, E each with a predefined distance I must put through which cities I passed (go through the matrix) then say the distance traveled, and / or the distance from one city to the other.

Reference:

  

link

    
asked by anonymous 25.02.2016 / 00:42

1 answer

3

Let's go beauty

algoritmo
declare mat[5,5], resultado[5,5], i, j, distancia numerico
para i <- 1 ate 5 faca
inicio
    para j <- 1 ate 5 faca
    inicio
        leia mat[i,j]
    fim
fim
distancia <- mat[1,1]
para i <- 1 ate 5 faca
inicio
    para j <- 1 ate 5 faca
    inicio
        se mat[i,j] > distancia entao
            distancia <- mat[i,j]
    fim
fim
para i <- 1 ate 5 faca
inicio
    para j <- 1 ate 5 faca
    inicio
        resultado[i,j] <- distancia * mat[i,j]
    fim
fim
para i <- 1 ate 5 faca
inicio
    para j <- 1 ate 5 faca
    inicio
        escreva resultado[i,j]
    fim
fim
fim_algoritmo.

// Adaptado de:
// ASCENCIO, A. F. G.; CAMPOS, E. A. V. Fundamentos da programação de
// computadores. 2a. ed. São Paulo: Pearson Prentice Hall, 2007. p. 198.

And now when someone asks you something of this code you will know how to respond? My tip is to see where you have questions, post a question or a problem that is verifiable so that colleagues here can give solutions;)

    
25.02.2016 / 15:07