


Hola tengo porblemas con las funciones de los juegos mayores(FULL POKER etc) cunado las compilo todo bien no me salta ningun error pero en el momento de ejecutarlas salen siempre true! y no encuentro cual puede ser el error...y tambien tengo problemas con el procedimiento cambiar dados q no me cambia los dados! si me pueden solucionar el error se los agradecerìa mucho1!(uso el compilador Free pascal compilater win32 para compilar) desde ya muchas gracias...
ro
Program generala;
uses
crt,dos;
type
matriz = array [1..2,1..5] of byte;
t_puntos= array [1..11, 1..5] of byte;
vector= array [1..6] of byte;
var
i,j:integer;
cant_jugadores:integer;
dados: matriz;
E,F,P,G,D: boolean;
tabla:t_puntos;
s:boolean;
{FUNCION QUE VALIDA EL INGRESO DE NUMEROS POR TECLADOS}
function validar:integer;
var
c:char;
s:string;
error:integer;
valid:integer;
begin
s:='';
repeat
repeat
c:=upcase(readkey);
until c in ['1','2','3','4','5','6','7','8','9',#13];
write (c);
if (c<>#13) then s:=s+c;
until (c=#13);
val (s,valid,error);
validar:=valid;
end;
procedure cambiardados (dados: matriz);
var
cambio:integer;
I,j: integer;
begin
writeln ('Elija el dado a cambiar, cero para no cambiar nada');
readln (cambio);
cambio:= validar;
while (cambio<>0) do
begin
if (dados[2,cambio]= 1) then
writeln ('Dado ya seleccionado, elija otro')
else
dados[2,cambio]:= 1;
end;
for j:= 1 to 5 do
begin
if (dados [2,i]= 1) then
begin
dados[1,i]:= random (6) + 1;
end;
end;
readkey;
end;
{FUNCION PARA SELECCIONAR CANTIDAD DE JUGADORES}
function seleccionar_cant_jugadores:byte;
var
aux:integer;
begin
repeat
writeln ('Ingrese la cantidad de jugadores');
aux:= validar;
if ((aux>5) or (aux<2)) then
writeln ('la cantidad de jugadores ingresados esta fuera de rango');
until (aux<6) and (aux>1);
seleccionar_cant_jugadores:=aux;
end;
{PRECEDIMIENTO QUE ORDENA LOS DADOS TIRADOS ANTERIORMENTE }
procedure ordenar (var dados: matriz);
var
i,j,k,aux: integer;
begin
for i:= 1 to 4 do
begin
aux:=dados[1,i];
k:= i;
for j:= (i+1) to 5 do
begin
if (dados [1,j]< aux) then
begin
aux:= dados [1,j];
k:= j;
end;
dados [1,k]:= dados [1,i];
dados [1,i]:= aux;
end;
end;
end;
{PROCEDIMIENTO QUE TIRA LOS DADOS}
procedure dado (dados: matriz);
var
color: byte;
i: integer;
j: integer;
begin
for i:= 1 to 5 do
begin
dados [1,i]:= random (6)+1;
dados [2,i]:= 0;
textcolor (10);
end;
ordenar(dados);
for j:= 1 to 5 do
write ('[',dados [1,j], ']');
writeln (' ');
writeln (' ');
readkey;
end;
{FUNCIONES QUE COMPRUEBAN SI HAY JUEGOS MAYORES}
function escalera (dados: matriz):boolean;
Begin
Ordenar (dados);
If ((Dados [1,1] = 1) and (Dados [1,2] = 2) and (Dados [1,3] = 3) and (Dados [1,4] = 4) and (Dados [1,5] = 5)) then
escalera:= true
else
if ((Dados [1,1] = 2) and (Dados [1,2] = 3) and (Dados [1,3] = 4) and (Dados [1,4] = 5) and (Dados [1,5] = 6)) then
escalera:=true
else
if ((Dados [1,1] = 1) and (Dados [1,2] = 3) and (Dados [1,3] = 4) and (Dados [1,4] = 5) and (Dados [1,5] = 6)) then
escalera:= true;
end;
function full (dados: matriz): boolean;
begin
ordenar (dados);
If ((Dados [1,1] = Dados [1,3]) and (Dados [1,4] = Dados [1,5]) and (Dados [1,1]<> Dados [1,4]))
or
((Dados [1,1] = Dados [1,2]) and (Dados [1,3] = Dados [1,5]) and (Dados [1,1]<> Dados [1,3])) then
full:= true;
end;
function poker (dados:matriz):boolean;
begin
ordenar(dados);
if (( dados[1,1] = dados[1,4] ) and ( dados[1,1] <> dados [1,5] )) then
poker:= true
else
if (( dados[1,2] = dados [1,5]) and ( dados [1,1]<> dados [1,2] )) then
poker:= true;
readkey;
end;
function generala (dados: matriz): boolean;
begin
ordenar (dados);
If (Dados [1,1] = Dados [1,5]) then
Generala := true;
end;
function doblegenerala (dados:matriz; g:boolean): boolean;
var
d: boolean;
begin
ordenar (dados);
if g then
d:= true;
end;
procedure jugadasmayores(e,f,p,g,d: boolean);
begin
if d then
writeln ('doble generala');
if g then
writeln ('generala');
if p then
writeln ('póker');
if f then
writeln ('full');
if e then
writeln ('escalera');
readkey;
end;
{PROGRAMA PRINCIPAL}
Begin
Randomize;
Clrscr;
cant_jugadores:=seleccionar_cant_jugadores;
Clrscr;
For i:=1 to 11 do
Begin
For j:=1 to cant_jugadores do
Begin
dado(Dados);
G:= Generala (Dados);
D:= Doblegenerala (dados,g);
P:= Poker (dados);
F:= full (dados);
E:= escalera (dados);
jugadasmayores(d,g,p,f,e);
cambiardados(dados);
end;
end;
readkey;
end.
Este es el codigo muchisismas gracias1

