Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program s2t1v ;
- uses WinCrt ;
- var
- csn,inn,tf : string;
- procedure randn(var csn : string);
- var
- vf : Boolean;
- b,a : integer;
- begin
- repeat
- str(random(8643)+1234,csn);
- vf := true;
- for a:=1 to 4 do
- for b:=1 to 4 do
- if (csn[a] = csn[b] ) and (a <> b ) then
- vf := false;
- Until vf = true
- End;
- procedure inpn(var inn : string ; tries : integer);
- var
- a,b,n : integer;
- vf : Boolean;
- begin
- repeat
- write(tries,'- N= ');
- readln(n);
- str(n,inn);
- vf := true;
- for a:=1 to 4 do
- for b:=1 to 4 do
- if (inn[a] = inn[b] ) and (a <> b ) then
- vf := false;
- until (vf = true ) and ( (n>=1000) and (n <=9999) );
- End;
- procedure check(var tf : string ;inn,csn : string ) ;
- var
- a,b,t,v : integer ;
- begin
- t:=0;
- v:=0;
- for a:=1 to 4 do
- for b:=1 to 4 do
- if (csn[a] = inn[b]) and (a = b ) then
- t:=t+1
- Else
- if (csn[a] = inn[b]) and (a <> b ) then
- v:=v+1;
- tf := chr(ord('0')+t)+'T'+chr(ord('0')+v)+'V' ;
- end;
- procedure aff(tf,inn,csn : string);
- var
- tries : integer;
- begin
- tries := 0 ;
- repeat
- tries:= tries+1;
- inpn(inn,tries);
- check(tf,inn,csn);
- if tf[1] <> '4' then
- writeln(tf);
- Until tf[1] = '4';
- writeln('congrats you found ',csn,' with ',tries,' attempts ');
- End;
- begin
- Randomize;
- randn(csn);
- writeln('csn',csn);
- aff(tf,inn,csn);
- End.
Advertisement
Add Comment
Please, Sign In to add comment