2
I’m a beginner and I need to solve a problem involving controlled repeating structures.
The problem is this: A Mega Sena player wants to know all the possible combinations the game allows and the total of them.
Dice:
Each card has 20 dozens
1 bet contains 6 tens.
tried that way:
algoritmo semNome;
// Síntese
// Objetivo: Saber todas as combinações possíveis e total de combinações da Mega Sena
// Entrada :
// Saída :
principal
// Declarações
inteiro a , b, c, d, r, f;
inteiro nc;
inteiro totdez;
// Instruções
totdez=20;
nc=1;
para (a de 1 ate totdez passo 1) faca
para (b de a+1 ate totdez passo 1) faca
para (c de 3 ate totdez passo 1) faca
para (d de c+1 ate totdez passo 1) faca
para (r de 5 ate totdez passo 1) faca
para (f de r+1 ate totdez passo 1) faca
escreval("Cartela n°", nc," ", a,",", b,",", c,",", d,",", r,",", f);
nc = nc +1;
fimPara
fimPara
fimPara
fimPara
fimPara
fimPara
nc = nc - 1;
escreval("O número total de resultados de ", totdez," é:", nc,".");
fimPrincipal
In itself it works but the tens keep repeating and getting infinite.
NOTE: This program was developed by the faculty itself, but it is almost the same thing as the visual.
May not have understood right your problem, but it is not only make a factorial of nc? ie factor of 20...?
– Luiz Augusto
Hi, how could I make that nc factorial?
– Insidious
https://answall.com/questions/197661/algoritmo-de-fatorial-em-portugol-studio this link will resolve the doubts of the factorial in portugol
– Luiz Augusto
Each command for part of the variable from the previous to plus 1. The end also goes from the first to totdez-5 to all-1 in the inner.
– anonimo