How to create an indeterminate algorithm using visualg?

1

I need to create an algorithm that returns different values each time I run, even though I get the same input values.

It aims to solve an issue where I need to analyze the generation of a certain living being who is more likely to have no children than to have, and to create an algorithm that calculates their generations as long as they have children, and say that it went extinct when there is no more children.

    
asked by anonymous 03.05.2016 / 20:16

1 answer

1

You can say that by putting a value in the variable x, it will make a draw, then every time you enter the same value will give a different value.

Example:

    var:
    x:inteiro; //Valor a ser inserido
    resultado:inteiro
    null:caracter
inicio
aleatorio on
    resultado
    aleatorio off
escreval("Digite o valor de x")
leia(x)
se x>=1 entao
escreval("resultado é= ")
leia(resultado)
senao
escreval("Campo vazio")
leia(null)

fimse
fimalgoritmo

link

I hope to have helped, even though it was rusty in portugol

    
03.05.2016 / 21:42