Program Project2; {$APPTYPE CONSOLE} uses SysUtils; Const n=30; m=1; var b,c:array[m..n] of integer; i,a,s,y,s1:integer; BEGIN Write('Vvedite trexsnachnoe chislo A: '); readln(a); y:=a; s:=0; while ( y<>0 ) do begin s:=s + (y mod 10); y:=y div 10; end; Writeln('Summa zifr ravna: ',s); Writeln; Writeln('Massiv: '); For i:=m to n do begin b[i]:=100+Random(200); Write(b[i],' '); c[i]:=b[i]; end; Writeln; Writeln; Write('Vse chisla, kotorye ravny po summe zifr: ') ; For i:=m to n do begin s1:=0; while ( b[i]<>0 ) do begin s1:=s1 + (b[i] mod 10); b[i]:=b[i] div 10; end; //Write(' ',S1,' '); If s=s1 then begin Write(c[i],' '); end; end; Readln; END.
{$APPTYPE CONSOLE}
uses SysUtils;
Const n=30;
m=1;
var b,c:array[m..n] of integer;
i,a,s,y,s1:integer;
BEGIN
Write('Vvedite trexsnachnoe chislo A: ');
readln(a);
y:=a; s:=0;
while ( y<>0 ) do
begin
s:=s + (y mod 10);
y:=y div 10;
end;
Writeln('Summa zifr ravna: ',s);
Writeln;
Writeln('Massiv: ');
For i:=m to n do
begin
b[i]:=100+Random(200);
Write(b[i],' ');
c[i]:=b[i];
end;
Writeln; Writeln;
Write('Vse chisla, kotorye ravny po summe zifr: ') ;
For i:=m to n do
begin
s1:=0;
while ( b[i]<>0 ) do
begin
s1:=s1 + (b[i] mod 10);
b[i]:=b[i] div 10; end;
//Write(' ',S1,' ');
If s=s1 then
begin
Write(c[i],' ');
end; end;
Readln;
END.