В программе буквы добавляются по алфавиту без повторений. var s1,s2:string; function F(var a,b:string):boolean; var m:set of char; i:integer; c:char; begin m:=[]; for i:=1 to length(a) do if pos(a[i],b)=0 then m:=m+[a[i]]; for c:=chr(32) to chr(255) do if c in m then a:=a+c; if m=[] then f:=false else f:=true; end; begin writeln('Введите строку 1:'); readln(s1); writeln('Введите строку 2:'); readln(s2); if f(s1,s2) then writeln('Новая строка: ',s1) else writeln('Строка не изменилась ');end.
Пример: Введите строку 1: program Введите строку 2: procedure Новая строка: programagm
const n = 2; k = 2; var i,j,s:integer; a:array[1..n,1..k] of integer; begin s:=0; for i:=1 to n do for j:=1 to k do begin Writeln('Введите a[',i,',',j,']:'); readln(a[i,j]); if a[i,j] mod 2=0 then s:=s+a[i,j]; end; if s<0 then for i:=1 to n do for j:=1 to k do if j mod 2=0 then a[i,j]:=1; if s>=0 then for i:=1 to n do for j:=1 to k do if j mod 2=0 then a[i,j]:=-1; for i:=1 to n do begin for j:=1 to k do write('a[':4,i,',',j,']=',a[i,j]); writeln; end; end.
var s1,s2:string;
function F(var a,b:string):boolean;
var m:set of char; i:integer; c:char;
begin
m:=[];
for i:=1 to length(a) do
if pos(a[i],b)=0 then m:=m+[a[i]];
for c:=chr(32) to chr(255) do
if c in m then a:=a+c;
if m=[] then f:=false else f:=true;
end;
begin
writeln('Введите строку 1:');
readln(s1);
writeln('Введите строку 2:');
readln(s2);
if f(s1,s2)
then writeln('Новая строка: ',s1) else writeln('Строка не изменилась ');end.
Пример:
Введите строку 1:
program
Введите строку 2:
procedure
Новая строка: programagm