1
I am doing a final work in the first semester of the BCC course and I need to do a Mega Sena algorithm with the following features:
- 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 must not be repeated
The language used is Portugol, but we use a specific platform created by students from the University, so there are small variations in the code semantics relative to the common Visualg.
My question is only about a specific part of the code that I could not solve the betting part 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 suppose the solution to this problem can be solved by going through the matrix completely and checking each bet, but I couldn’t find a working method for it.
Anyone who can help, feel free to use the C language itself.
The requirement is even "if the user bets the number 1, the number 1 can no longer be used by anyone"? Strange that!
– bfavaretto
Well, that’s what I understood, but I may have misread it. The statement says "It should be noted that the numbers bet cannot be repeated and must be chosen from the values 1 to 60". I imagine I made a little mistake... Player 1 bet: 1,2,3,4,5,6.. he won’t be able to bet the 1 again, but other players can bet the 1, maybe...
– João Iora
Or maybe the restriction is that there can be no repeating numbers in the same bet (ex: 1 1 2 3 3), as in real mega sena.
– bfavaretto
I imagine that’s right, but I still haven’t been able to implement such validation correctly in the code.. I suppose I should go through the whole vector and check if the number is there, but every time I try, I get an error saying that the vector has not been initialized.
– João Iora
The method would be the same, but I can not help you with this code, because I know little of C and even less of Portugol. The error you quoted is from portugol or c compiler?
– bfavaretto
It’s from Portugol itself.
– João Iora
Try to post code instead of code image. I don’t know if Portugol has Syntax Highlight, but maybe another language will do.
– brasofilo
Calango itself already has Syntax Highlight. The words in blue are the reserved words.
– João Iora