Scroll through an array and validate repeated numbers

I am doing a final work in the first semester in the BCC course and I need to make a Mega Sena algorithm with the following characteristics:

  • maximum of 10 players
  • each player must bet a minimum of 6 numbers and a maximum of 15 numbers
  • valid numbers range from 1 to 60
  • bets cannot be repeated

The language used is Portugol, but we use a specific platform created by students from University, so there are small variations in the semantics of the code in relation to the common Visualg.

My doubt is in relation to only a specific part of the code that I could not solve the part of bets do not repeat. If the user bets the number 1, the number 1 can no longer be used by anyone. Follows image of the code.

I assume that the resolution for this problem can be solved by going through the array completely and checking each bet, but not I was able to find a functional method for this.

Anyone who can help, feel free to use the C language itself.

Author: brasofilo, 2014-05-27

1 answers

Before the vector [counter1] [counter2] receive the bet, knife a loop (to...knife) to check if the informed bet is already within the vector. If it does, it asks the user to enter the number again.

Something like:

leia(apostas);

para (contador3 de 1 ate 15) faca
       se (vetor[contador1][contador3] = apostas)
          ir para (goto) leia(apostas);      
fimpara
 1
Author: Heber, 2014-05-27 23:07:37