Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
Program SelfDescribingNumber;
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
function check(number: longint): boolean;
|
||||
var
|
||||
i, d: integer;
|
||||
a: string;
|
||||
count, w : array [0..9] of integer;
|
||||
|
||||
begin
|
||||
a := intToStr(number);
|
||||
for i := 0 to 9 do
|
||||
begin
|
||||
count[i] := 0;
|
||||
w[i] := 0;
|
||||
end;
|
||||
for i := 1 to length(a) do
|
||||
begin
|
||||
d := ord(a[i]) - ord('0');
|
||||
inc(count[d]);
|
||||
w[i - 1] := d;
|
||||
end;
|
||||
check := true;
|
||||
i := 0;
|
||||
while check and (i <= 9) do
|
||||
begin
|
||||
check := count[i] = w[i];
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
x: longint;
|
||||
|
||||
begin
|
||||
writeln ('Autodescriptive numbers from 1 to 100000000:');
|
||||
for x := 1 to 100000000 do
|
||||
if check(x) then
|
||||
writeln (' ', x);
|
||||
writeln('Job done.');
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue