Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program h1;
- var
- n,m,p,i : integer;
- a,b,c,d,e : byte;
- begin
- ReadLn(n);
- for i:=1 to n do
- begin
- a:=i mod 10;
- b:=(i mod 100) div 10;
- c:=(i mod 1000) div 100;
- d:=(i mod 10000) div 1000;
- e:=i div 10000;
- if (e>0) and (d>0) and (c>0) and (b>0) and (a>0) then m:=10000*a + 1000*b + 100*c + 10*d + e
- else if (e=0) and (d>0) and (c>0) and (b>0) and (a>0) then m:=1000*a + 100*b + 10*c + d
- else if (e=0) and (d=0) and (c>0) and (b>0) and (a>0) then m:=100*a + 10*b + c
- else if (e=0) and (d=0) and (c=0) and (b>0) and (a>0) then m:=10*a + b
- else if (e=0) and (d=0) and (c=0) and (b=0) and (a>0) then m:=i
- else m:=0;
- if (m<=n) and (m>0) then
- begin
- Inc(p);
- WriteLn(i, '=',e,d,c,b,a, ' : ', m);
- end;
- end;
- WriteLn('Turnbacks: ', p);
- end.
Add Comment
Please, Sign In to add comment