program sorte;
uses
CRT;
var
euros:array[1..5] of byte;
totoloto:array[1..6] of byte;
cont, cont2, testenumero, testenovo, numero, naux, nchaves, cont3,nada: byte;
estrelas:array[1..2] of byte;
op, resp: char;
sair:boolean;
begin
repeat
begin
CLRSCR;
sair:=false;
TEXTCOLOR(22);
gotoXY (10,7);
writeln('Bem-Vindo ao gerador de chaves para o Euromilhoes e Totoloto');
writeln();
gotoXY (35,9);
writeln('Boa Sorte!');
writeln();
writeln();
TEXTCOLOR(2);
gotoXY (32,14);
Writeln ('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
TEXTCOLOR(2);
gotoXY (32,15);
Writeln ('º1-Euromilhoesº');
TEXTCOLOR(14);
gotoXY (32,16);
Writeln ('º2-Totoloto º');
TEXTCOLOR(4);
gotoXY (32,17);
writeln ('º3-Sair º');
gotoXY (32,18);
writeln ('ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ');
gotoXY (32,19);
Readln (op);
while (op<'1') or (op>'3') do
begin
CLRSCR;
TEXTCOLOR(22);
gotoXY (20,12);
writeln('Opcao invalida, insira novamente');
writeln();
writeln();
TEXTCOLOR(2);
gotoXY (32,14);
Writeln ('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
TEXTCOLOR(2);
gotoXY (32,15);
Writeln ('º1-Euromilhoesº');
TEXTCOLOR(14);
gotoXY (32,16);
Writeln ('º2-Totoloto º');
TEXTCOLOR(4);
gotoXY (32,17);
writeln ('º3-Sair º');
TEXTCOLOR(15);
gotoXY (32,18);
writeln ('ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ');
gotoXY (32,19);
Readln (op);
end;
case op of
'1': begin
TEXTCOLOR(15);
gotoXY(26,21);
writeln ('ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
gotoXY(26,22);
writeln('³Quantas chaves deseja ver?³');
gotoXY(26,23);
writeln ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
gotoXY(27,24);
readln(nchaves);
while (nchaves<1) or (nchaves>10) do
begin
gotoXY(13,26);
writeln('O numero de chaves inserido ‚ inv lido, insira novamente.');
gotoXY(14,27);
readln(nchaves);
end;
for cont2:=1 to nchaves do
begin
Randomize;
euros[1]:= Random(50)+1;
testenovo:=1;
cont:=1;
while cont<=4 do
begin
Randomize();
numero:=Random(50)+1;
testenumero:=1;
while testenumero<=cont do
begin
if numero=euros[cont] then
begin
Randomize();
numero:=Random(50)+1;
testenumero:=0;
end;
testenumero:=testenumero+1;
end;
cont:=cont+1;
euros[cont]:=numero;
end;
for cont3:=1 to 5 do
begin
for cont:=1 to 5 do
begin
if euros [cont3]<euros[cont] then
begin
naux:=euros [cont3];
euros[cont3]:=euros[cont];
euros[cont]:=naux;
end;
end;
end;
Randomize;
estrelas[1]:=Random(9)+1;
cont:=1;
while cont<2 do
begin
Randomize;
numero:= Random(9)+1;
testenumero:=1;
while testenumero<=cont do
begin
if numero=estrelas[cont] then
begin
Randomize();
numero:= Random(9)+1;
testenumero:=0;
end;
testenumero:=testenumero+1;
end;
cont:=cont+1;
estrelas[cont]:=numero;
for cont3:=1 to 2 do
begin
for cont:=1 to 2 do
begin
if estrelas[cont3]<estrelas[cont] then
begin
naux:= estrelas[cont3];
estrelas[cont3]:=estrelas[cont];
estrelas[cont]:=naux;
end;
end;
end;
writeln('A chave gerada foi:');
writeln();
writeln('Numeros:');
for cont:=1 to 5 do
begin
writeln ('ÚÄÄ¿');
write('³',euros[cont],'³');
writeln();
writeln ('ÀÄÄÙ');
end;
writeln();
writeln('Estrelas:');
for cont:=1 to 2 do
begin
writeln ('ÚÄ¿');
writeln('³',estrelas[cont],'³');
writeln ('ÀÄÙ');
end;
readln(nada);
end;
end;
end;
'2': begin
TEXTCOLOR(15);
gotoXY(26,21);
writeln ('ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
gotoXY(26,22);
writeln('³Quantas chaves deseja ver?³');
gotoXY(26,23);
writeln ('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
gotoXY(27,24);
readln(nchaves);
while (nchaves<1) or (nchaves>10) do
begin
gotoXY(13,26);
writeln('O numero de chaves inserido ‚ inv lido, insira novamente.');
gotoXY(14,27);
readln(nchaves);
end;
for cont2:=1 to nchaves do
begin
Randomize;
totoloto[1]:=Random(49)+1;
cont:=1;
while cont<=5 do
begin
Randomize();
numero:=Random(49)+1;
testenumero:=1;
while testenumero <=cont do
begin
if numero=totoloto[cont] then
begin
Randomize();
numero:=Random(49)+1;
testenumero:=0;
end;
testenumero:=testenumero+1;
end;
cont:=cont+1;
totoloto[cont]:=numero;
end;
for cont3:=1 to 6 do
begin
for cont:=1 to 6 do
begin
if totoloto[cont3]< totoloto[cont] then
begin
naux:=totoloto [cont3];
totoloto[cont3]:=totoloto[cont];
totoloto[cont]:=naux;
end;
end;
end;
writeln('A sua chave do Totoloto ‚: ');
for cont:=1 to 6 do
begin
writeln ('ÚÄÄ¿');
writeln('³',totoloto[cont],'³');
writeln ('ÀÄÄÙ');
end;
readln(nada);
end;
end;
'3': begin
CLRSCR;
writeln ('Deseja sair do programa sair?');
writeln ('S');
writeln ('ou');
writeln();
writeln ('N');
readln (resp);
while (resp<> 'S') and (resp<> 's') and (resp<>'N') and (resp<>'n') do
Begin
writeln ('Resposta invalida');
readln (resp);
End;
if (resp='s') or (resp='S') then
begin
sair:=true;
end;
End;
end;
end;
Until Sair=True;
End.