Задача 8 Урок 17

Задача 8 Урок 17

Проверить можно ли строки из m перестановкой символов получить строку n.

var s, n:string; i,j:integer;
begin
  s:='sdfgh';
  n:='hsfgd';
  if length(n)<>length(s) then
    writeln('net')
  else
  begin
    for i:=1 to length(n) do
    begin
      for j:=1 to length(s) do
        if n[i]=s[j] then
        begin
          s[j]:='*';
          n[i]:='*';
          break;
        end;
      if (n[i]<>s[j]) and (j=length(s)) then
        break;
    end;
  if s=n then
    writeln('da');
  end;
  readln();
end.