PascalABC.NET 3.3.5, сборка 1650 от 01.04.2018 Внимание! Если программа не работает, обновите версию!
function Sod(Self:integer):integer; extensionmethod; begin Result:=0; while Self<>0 do begin Result+=Self mod 10; Self:=Self div 10 end end;
function IsGood(Self:integer):boolean; extensionmethod; begin var sd:=Self.Sod; Result:=True; for var i:=2 to 9 do begin Result:=(i*Self).Sod=sd; if Result=False then Exit end end;
begin var (a,b):=ReadInteger2; Range(a,b).Where(t->t.IsGood).Println end.
//Я просто опишу метод записи матрицы const n=100; var ar:array of array of integer; ars:array of array of string; i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string); var i,j:integer; begin; for i:=1 to n do begin; for j:=1 to n do begin; ar[i,j]:=random(9); str(ar[i,j],ars[i,j]); end; end; end;
procedure burning(ars:array of array of string); var i,j:integer; t:text; begin; assign(t,'text.txt'); rewrite(t); for i:=1 to n do begin; writeln(t,' '); for j:=1 to n do write(t,ars[i,j],' '); end; end;
begin; randomize; setlength(ar,n+1); setlength(ars,n+1); for i:=1 to n do begin; setlength(ar[i],n+1); setlength(ars[i],n+1); end; complection(ar,ars); burning(ars); end.
Внимание! Если программа не работает, обновите версию!
function Sod(Self:integer):integer; extensionmethod;
begin
Result:=0;
while Self<>0 do begin
Result+=Self mod 10;
Self:=Self div 10
end
end;
function IsGood(Self:integer):boolean; extensionmethod;
begin
var sd:=Self.Sod; Result:=True;
for var i:=2 to 9 do begin
Result:=(i*Self).Sod=sd;
if Result=False then Exit
end
end;
begin
var (a,b):=ReadInteger2;
Range(a,b).Where(t->t.IsGood).Println
end.
Пример
1 1000
9 18 45 90 99 180 198 297 396 450 495 549 594 693 792 819 891 900 909 918 945 990 999
const n=100;
var ar:array of array of integer;
ars:array of array of string;
i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string);
var
i,j:integer;
begin;
for i:=1 to n do
begin;
for j:=1 to n do
begin;
ar[i,j]:=random(9);
str(ar[i,j],ars[i,j]);
end;
end;
end;
procedure burning(ars:array of array of string);
var
i,j:integer;
t:text;
begin;
assign(t,'text.txt');
rewrite(t);
for i:=1 to n do
begin;
writeln(t,' ');
for j:=1 to n do
write(t,ars[i,j],' ');
end;
end;
begin;
randomize;
setlength(ar,n+1);
setlength(ars,n+1);
for i:=1 to n do
begin;
setlength(ar[i],n+1);
setlength(ars[i],n+1);
end;
complection(ar,ars);
burning(ars);
end.