Pascal/Turbo Pascal - ayuda con Pascal, Euromillones

 
Vista:

ayuda con Pascal, Euromillones

Publicado por Riccardo (3 intervenciones) el 19/09/2011 16:54:16
Hola a todos, estoy empezando con Pascal, y me gustaria hacer un programa donde voy a poner los numeros jugados, de diferentes jugadores, al Euromillones y los sorteados. El programa me tiene que decir quien a ganado y con cual combinacion. A el Euromillone se juegan 5 numeros y dos numeros estrellas. Mucha gracias a quien me quiere ayudar. Un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

ayuda con Pascal, Euromillones

Publicado por ramon (2158 intervenciones) el 21/09/2011 21:36:21
{Conoces estas estructuras dímelo para seguir }

program Euromill;
uses
crt;
type

tableta = record
bono = array[1..50] of integer;
estre = array[0..9] of integer;
end;

var
jugador : array[1..100] of tableta;
cont : integer;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

ayuda con Pascal, Euromillones

Publicado por Riccardo (3 intervenciones) el 22/09/2011 15:36:32
Grazias Ramon para contestarme. Hasta ahora entendio la estructura. Mi problema es encontrar una formula que lea los numeros introduidos y el programa vaya a leer la cadenas de numeros de cada jugador e diga cuantos numeros hay de igual. Espero che no te sea de molestia. Espero tu respuesta.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

ayuda con Pascal, Euromillones

Publicado por ramon (2158 intervenciones) el 23/09/2011 18:09:25
{A ver si esto te ayuda}


program Euromill;
uses
crt;
type

tableta = record
nomb : string[20];
bono : array[1..50] of word;
estra : array[0..1] of word;
acierto : integer;
esta : integer;
end;

var
jugador : array[1..20] of tableta;
valort, erro, t, ver, cont : integer;
sorteo : array[1..5] of word;
losest : array[0..1] of word;


procedure pon_inicio;
var
k : integer;
begin
for k := 1 to 20 do
begin
fillchar(jugador[k].bono,sizeof(jugador[k].bono),0);
fillchar(jugador[k].estra,sizeof(jugador[k].estra),10);
end;
end;

function ponestras(nn : integer) : word;
var
tec : char;
dato : string[2];
nt : word;
i, error : integer;
xd, yd : integer;
begin
i := 1;
ponestras := 0;
xd := 20;
yd := 7;
gotoxy(3,7);write('Entre N§ ',nn,' Estra : ');
gotoxy(21,7);
repeat
tec := readkey;
if tec in[#48..#57] then
begin
dato[i] := tec;
dato[0] := chr(i);
gotoxy(xd + i,yd);write(dato[i]);
i := i + 1;
if i > 2 then
begin
i := 2;
end;
end;
if tec = #8 then
begin
i := i - 1;
if i < 1 then
begin
i := 1;
end;
dato[i] := ' ';
dato[0] := chr(i);
gotoxy(xd + i,yd);write(dato[i]);
end;
until tec = #13;
val(dato,nt,error);
ponestras := nt;
gotoxy(xd,yd);clreol;
end;


procedure asignanumeros;
var
x, y, l, i : integer;
numero : string[2];
pulsa, tecla : char;
final : boolean;
nombre : string[20];
est : word;
begin
final := false;
x := 20;
y := 7;
cont := 1;
repeat
i := 1;
l := 1;
fillchar(jugador[cont].bono,sizeof(jugador[cont].bono),0);
gotoxy(10,2);write('Nombre Comprador : ');
gotoxy(29,2);readln(nombre);
jugador[cont].nomb := copy(nombre,1,length(nombre));
gotoxy(10,4);write('Entre 5 numeros del 1 al 50 ');
gotoxy(10,5);write('Pulse [ENTER] para aceptar');
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
repeat
tecla := readkey;
if tecla in[#48..#57] then
begin
numero[l] := tecla;
numero[0] := chr(l);
gotoxy((x - 1) + l,y);write(numero[l]);
l := l + 1;
if l > 2 then
l := 2;
end;
if tecla = #8 then
begin
l := l - 1;
if l < 1 then
l := 1;
numero[l] := ' ';
numero[0] := chr(l);
gotoxy((x - 1) + l,y);write(numero[l]);
end;
if tecla = #13 then
begin
val(numero,valort,erro);
if (valort > 50) or (valort = 0) then
begin
x := 20;
l := 1;
gotoxy(10,7);clreol;
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
end
else
begin
jugador[cont].bono[valort] := valort;
i := i + 1;
x := 20;
l := 1;
gotoxy(10,7);clreol;
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
end;
end;
until i > 5;
jugador[cont].estra[0] := 10;
jugador[cont].estra[1] := 10;
est := ponestras(1);
jugador[cont].estra[0] := est;
est := ponestras(2);
jugador[cont].estra[1] := est;
gotoxy(10,24);write('Desea Entrar mas Bonos [S/N]');
repeat
pulsa := readkey;
until pulsa in['n','N','s','S'];
if pulsa in['n','N'] then
begin
final := true;
end
else
begin
y := y + 1;
x := 20;
cont := cont + 1;
end;
gotoxy(10,24);clreol;
until final = true;
end;

procedure entrada_sorteados;
var
x, y, l, i : integer;
numero : string[2];
pulsa, tecla : char;
final : boolean;
est : word;
begin
clrscr;
i := 1;
l := 1;
x := 19;
y := 7;
gotoxy(10,4);write('Entre 5 numeros del 1 al 50 ');
gotoxy(10,5);write('Pulse [ENTER] para aceptar');
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
repeat
tecla := readkey;
if tecla in[#48..#57] then
begin
numero[l] := tecla;
numero[0] := chr(l);
gotoxy((x - 1) + l,y);write(numero[l]);
l := l + 1;
if l > 2 then
l := 2;
end;
if tecla = #8 then
begin
l := l - 1;
if l < 1 then
l := 1;
numero[l] := ' ';
numero[0] := chr(l);
gotoxy((x - 1) + l,y);write(numero[l]);
end;
if tecla = #13 then
begin
val(numero,valort,erro);
if (valort > 50) or (valort = 0) then
begin
x := 20;
l := 1;
gotoxy(10,7);clreol;
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
end
else
begin
sorteo[i] := valort;
i := i + 1;
x := 20;
l := 1;
gotoxy(10,7);clreol;
gotoxy(10,7);write('N§ : ',i);
gotoxy((x - 1) + l,y);
end;
end;
until i > 5;
losest[0] := 10;
est := ponestras(1);
losest[0] := est;
losest[1] := 10;
est := ponestras(2);
losest[1] := est;
end;

procedure ganador;
var
xa, i, z, bon, it : integer;
begin
jugador[bon].acierto := 0;
bon := 1;
repeat
i := 1;
repeat
for z := 1 to 5 do
begin
if jugador[bon].bono[i] = sorteo[z] then
begin
jugador[bon].acierto := jugador[bon].acierto + 1;
end;
end;
i := i + 1;
until i > 50;
bon := bon + 1;
until bon > 20;
bon := 1;
repeat
for i := 0 to 1 do
begin
if jugador[bon].estra[i] = losest[i] then
begin
jugador[bon].esta := jugador[bon].esta + 1;
end;
end;
bon := bon + 1;
until bon > 20;
xa := 0;
for bon := 1 to 20 do
begin
if (jugador[bon].acierto = 5) and (jugador[bon].esta = 2) then
{PLENO}
begin
gotoxy(10,4);write(jugador[bon].nomb);
gotoxy(10,6);write('Numeros EuroMillones');
for i := 1 to 50 do
begin
if jugador[bon].bono[i] > 0 then
begin
gotoxy(10 + xa,8);write(jugador[bon].bono[i]);
xa := xa + 4;
end;
end;
end;
xa := 0;
gotoxy(10,10);write('Numeros Extrellas');
for i := 0 to 1 do
begin
if jugador[bon].estra[i] < 10 then
begin
gotoxy(10 + xa,12);write(jugador[bon].estra[i]);
xa := xa + 4;
end;
end;
{Puede ser 4 y 1 o}
{Otras combinaciones}
end;
readln;
end;

procedure encuadre(xn, yn : integer; estado : boolean);
begin
if estado = true then
begin
gotoxy(xn,yn);write('----------------------');
gotoxy(xn,yn + 2);write('----------------------');
gotoxy(xn - 1,yn + 1);write('|');
gotoxy(xn + 22,yn + 1);write('|');
end;
if estado = false then
begin
gotoxy(xn,yn);write(' ');
gotoxy(xn,yn + 2);write(' ');
gotoxy(xn - 1,yn + 1);write(' ');
gotoxy(xn + 22,yn + 1);write(' ');
end;
end;

procedure menu;
var
opcion : char;
opci, xm, ym : integer;
final : boolean;
begin
gotoxy(10,3);write('**** Menu General ****');
gotoxy(10,6);write('Entrada N§ Bonos');
gotoxy(10,8);write('Entrada N§ Sorteados');
gotoxy(10,10);write('Presentacion Ganador');
gotoxy(10,12);write('Salir');
gotoxy(10,16);write('USE LAS FLECHAS [ ] [ ] Y [ENTER]');
gotoxy(28,16);write(chr(25));
gotoxy(34,16);write(chr(24));
xm := 10;
ym := 5;
encuadre(xm,ym,true);
opci := 1;
final := false;
repeat
opcion := readkey;
encuadre(xm,ym,false);
if opcion = #80 then
begin
opci := opci + 1;
if opci > 4 then
opci := 4;
ym := ym + 2;
if ym > 11 then
ym := 11;
end;
if opcion = #72 then
begin
opci := opci - 1;
if opci < 1 then
opci := 1;
ym := ym - 2;
if ym < 5 then
ym := 5;
end;
if opcion = #13 then
begin
clrscr;
case opci of
1 : asignanumeros;
2 : entrada_sorteados;
3 : ganador;
4 : final := true;
end;
clrscr;
gotoxy(10,3);write('**** Menu General ****');
gotoxy(10,6);write('Entrada N§ Bonos');
gotoxy(10,8);write('Entrada N§ Sorteados');
gotoxy(10,10);write('Presentacion Ganador');
gotoxy(10,12);write('Salir');
gotoxy(10,16);write('USE LAS FLECHAS [ ] [ ] Y [ENTER]');
gotoxy(28,16);write(chr(25));
gotoxy(34,16);write(chr(24));
encuadre(xm,ym,true);
end;
encuadre(xm,ym,true);
until final = true;
end;

begin
clrscr;
pon_inicio;
{asignanumeros;
entrada_sorteados;
ganador;}
menu;

end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

ayuda con Pascal, Euromillones

Publicado por Riccardo (3 intervenciones) el 26/09/2011 16:49:45
Gracias Ramon, hace 6 meses que estudio el Pascal y todavia habia cosas que no entendia. Creo que este programa me ayudarà a mover mi primer pasos. Me pongo al trabajo y te avisarè si hay algunas dudas. Tu ayuda ha sido genial. Ya te pagarè una canya....Hasta pronto...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar