• Lenguaje

    Pascal

  • Descripción

    Genere número aleatorio de 1 a 38 si es loto normal y de 1 a 10 si es loto mas. Debe hacer un menú para seleccionar loto normal o loto mas.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
program LotoNormalYLotoMas;
uses crt;

var loto, numero_aleatorio, rand : integer;
begin
    write ('Ingresa el valor de rand: ');
    readln (rand);
    writeln ('Selecciona el valor de loto.');
    writeln ('    1.- loto normal');
    writeln ('    2.- loto mas');
    write ('    : ');
    repeat
        readln (loto);
        if (loto<1) or (loto>2) then
            write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
    until (loto>=1) and (loto<=2);
    if loto=1 then
        begin
            numero_aleatorio := 1+rand() mod 38;
        end
    else
        begin
            numero_aleatorio := 1+rand() mod 10;
        end;
    writeln ('Valor de numero aleatorio: ', numero_aleatorio);
    writeln;
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.