tipo na roba del genere andrebbe bene????
program Mastermind;
uses Crt;
var k,h,i,ps,pg,contatore: integer;
var a,b:array[1..4] of integer;
begin
repeat
writeln('inserisci quattro numeri <=9');
for i:=1 to 4 do
readln(a);
until (a[1]>0)
and (a[2]>0)
and (a[3]>0)
and (a[4]>0)
and (a[1]<10)
and (a[2]<10)
and (a[3]<10)
and (a[4]<10);
repeat
repeat
writeln('inserisci 4 numeri in sequenza');
if contatore>=6 then
writeln('sbagliato')
else;
for i:=1 to 4 do
readln(b);
until (b[1]>0)
and (b[2]>0)
and (b[3]>0)
and (b[4]>0)
and (b[1]<10)
and (b[2]<10)
and (b[3]<10)
and (b[4]<10);
ps:=0;
pg:=0;
for x:=1 to 4 do
begin
for y:=1 to 4 do
if a[x]=b[y] then
ps:=ps+1
else;
if a[x]=b[x] then
begin
ps:=ps-1;
pg:=pg+1;
end
else;
end;
contatore:=contatore + 1;
writeln('Numeri giusti al posto sbagliato:',ps);
writeln('Numeri giusti al posto giusto:', pg);
until (conta=10);
until (pg=4);
if conta=10 then
write('troppi tentativi,a[1],a[2],a[3],a[4])
else
write('Hai vinto, hai provato ',contatore);
writeln('possibilità');
end;
readln;
end.
|