var s : string[50]; i, j, k : word; f : boolean; function isSpace(ch : char) : boolean; begin isSpace := false; if ch = ' ' then isSpace := true; end; begin f := false; repeat j := 0; writeln('введите строку, состоящую из 2 слов'); readln(s); for i := 1 to length(s) do if isSpace(s[i]) then begin inc(j); k := i; end; if j =1 then f := true; until f; write(copy(s, k + 1, length(s)), ' ', copy(s, 1, k - 1)); end. недавно такую писала :)
const
MAX = 20;
var
s:string;
stack:array[1..MAX] of string;
top:integer;
i:byte;
procedure Push(ch:string);
begin
if top>=MAX then WriteLn('Stask full')
else
begin
stack[top]:=ch;
top:=top+1;
end;
end;
function Pop:string;
begin
top:=top-1;
if top<1 then
begin
WriteLn('Stack underflow');
top:=top+1;
end
else Pop := stack[top];
end;
begin
top:=1;
s:='<asdf<asdf>asdf>';//правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
top:=1;
s:='<asdf<asdfasdf>';//не правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
end.
Объяснение: