Help with programming in Portugal

Asked

Viewed 165 times

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...?

  • Hi, how could I make that nc factorial?

  • https://answall.com/questions/197661/algoritmo-de-fatorial-em-portugol-studio this link will resolve the doubts of the factorial in portugol

  • 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.

No answers

Browser other questions tagged

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