How to create an undetermined algorithm using visualg?

Asked

Viewed 693 times

1

I need to create an algorithm that returns me different values each time it is executed, even receiving the same input values.

It aims to solve a question where I need to analyze the generation of a particular living being who has more chances of not having children than of having, and create an algorithm that calculates their generations as long as they have children, and say that it went extinct when there are no more children.

  • 1

    What would be undetermined?

  • 1

    An algorithm that returns me different values each time it runs, even when receiving the same input values.

  • Already improved a bit, edit the question and add this description in the question :)

  • Sorry, I’m new to the forum and younger still in the course of Computer Systems, so I’m a little lost. I need to solve a question that asks how many generations a living being will last, and he is more likely not to have children than to have... then I need to create an algorithm that tells how many children he has had generation after generation, until it goes extinct.

  • 1

    When you get a chance see the tour she explains quickly how the site works, it is a Q&A and not a forum, I imagine that the first of several questions.

1 answer

1

You can say that when you put a value in 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

https://www.youtube.com/watch?v=nUxdrZLj9uk

I hope I helped, even though I was rusty in the port

Browser other questions tagged

You are not signed in. Login or sign up in order to post.