Var s,i:integer;
begin
write('s = ');
readln(s);
for i:=100 to 999 do
if (i div 100 + i div 10 mod 10 + i mod 10 < s)
then write(i,' ');
end.
Пример:
<span>s = 5
100 101 102 103 110 111 112 120 121 130 200 201 202 210 211 220 300 301 310 400 </span>
//Код, уродливый как кхм
//Pascal ABC.NET 3.1 сборка 1219
Const
n=1;
m=2;
Var
ar1:array[1..m] of integer;
ar2:array[1..n] of integer;
arr:array[1..n+m] of integer;
i,p,raz,ost,isec:integer;
begin
write('Введите основание СС:');
readln(p);
writeln('Введите число 1:');
for i:=1 to m do
readln(ar1[i]);
writeln('Введите число 2:');
for i:=1 to n do
readln(ar2[i]);
if n>m then
begin
i:=n;
isec:=m;
while (i<>0) and (isec<>0) do
begin
if ar2[i]+ar1[isec]>=p then
begin
ost:=(ar2[i]+ar1[isec]) div p;
arr[i]:=(ar2[i]+ar1[isec]) mod p;
end
else
begin
arr[i]:=ar2[i]+ar1[isec]+ost;
ost:=0;
end;
dec(i);
dec(isec);
inc(raz);
end;
arr[i]:=ost;
ost:=i;
for i:=1 to ost do
begin
arr[i]:=arr[i]+ar2[i];
inc(raz);
end;
while arr[1]>=p do
begin
ost:=arr[1] div p;
arr[1]:=arr[1] mod p;
for i:=raz downto 1 do
arr[i+1]:=arr[i];
arr[1]:=ost;
inc(raz);
end;
end
else
begin
i:=m;
isec:=n;
while (i<>0) and (isec<>0) do
begin
if ar1[i]+ar2[isec]>=p then
begin
ost:=(ar1[i]+ar2[isec]) div p;
arr[i]:=(ar1[i]+ar2[isec]) mod p;
end
else
begin
arr[i]:=ar1[i]+ar2[isec]+ost;
ost:=0;
end;
dec(i);
dec(isec);
inc(raz);
end;
if n<>m then
begin
arr[i]:=ost;
ost:=i;
for i:=1 to ost do
begin
arr[i]:=arr[i]+ar1[i];
inc(raz);
end;
end
else
begin
for i:=raz downto 1 do
arr[i+1]:=arr[i];
arr[1]:=ost;
inc(raz);
end;
while arr[1]>=p do
begin
ost:=arr[1] div p;
arr[1]:=arr[1] mod p;
for i:=raz downto 1 do
arr[i+1]:=arr[i];
arr[1]:=ost;
inc(raz);
end;
end;
writeln('Result:');
for i:=1 to raz do
write(arr[i]:4);
end.
Пример работы программы:
Введите основание СС:3
Введите число 1:
2
2
Введите число 2:
1
Result:
1 0 0
1) если введённое число попадёт в промежуток от 1 до 11, то программа выполнит сложение 0+ введённое число и выведет результат.
Например,
Вводим 3, 0+3=3, программа выведет 3
2) аналогично
<span>var s : string; symb : char; i : longint;
begin
readln(s);
readln(symb);
if pos(symb,s)=0 then writeln('В этом слове нет этого символа')
else begin
i:=0;
while pos(symb,s)<>0 do begin
write(pos(symb,s)+i,' ');
i:=i+1;
Delete(s,pos(symb,s),1);
end;
end;
writeln;
writeln(i);
end.</span>
Var a:array[0..100] of integer;
<span>i,n:integer; </span>
<span>begin </span>
<span>read(n); </span>
<span>for i:=0 to n-1 do begin read(a[i]); </span>
<span>if i mod 2=0 then a[i]:=1 else </span>
<span>a[i]:=i mod 5; </span>
<span>end; </span>
<span>for i:=0 to n-1 do write(a[i],' '); </span>
<span>end.</span>