Difficulty with loop (repetition) in Portuguese

2

I have this exercise to do:

  

Make a program that asks the user for the number of   energy in a region, after reading this amount of power plants, the   asks for each plant which type of plant (h-hydroelectric T-   E-thermoelectric and what the generated power, after reading the data   of all plants, the program counts the total energy generated   for each type and evaluates on which flag the region should operate. When   more than 20% of generation generated is from thermoelectric   it is operated on red flag. when the thermoelectric generation is   between 10 and 20% the region operates in yellow flag.

But I'm having a hard time. I did this part of the code, but I can not get the repetition to work in a way that repeats itself to the number of mills entered by the user:

algoritmo "semnome"
// Função :
// Autor :
// Data : 08/05/2015

// Seção de Declarações
var nu,cont :inteiro tipo :caractere

inicio

    cont <- 1
    escreval("digite a qtd de usinas")
    leia (nu)
    repita
        escreval("digite o tipo de cada usina ")
        leia(tipo)
    ate (cont = nu)
    // Seção de Comandos

fimalgoritmo
    
asked by anonymous 08.05.2015 / 14:18

1 answer

2

You have a loop to request the type of power plants. Your control condition is:

até (cont = nu)

being nu the number of mills entered by the user. The variable cont is your loop counter, which you correctly initialize with 1 in:

cont <- 1

The problem with your tie is that it does not end , because you do not update the control variable cont . To do this, within the loop, and as the last instruction, increase by 1 unit this variable (to indicate that 1 plant has already been processed):

repita
    [...]
    cont <- cont + 1
até (cont = nu)
    
08.05.2015 / 14:34