Определите, сколько слов заданного текста составлено из букв русского алфавита, а сколько — из букв латинского алфавита. Слова, в которых встречаются буквы обоих алфавитов, замените словом «Error» — Pascal(Паскаль)

const
  s: string= 'qwerty аааaaa йцукен, asdf фыва? zxcv nmть';
  lat= ['A'..'Z']+['a'..'z'];
  rus= ['А'..'Я']+['а'..'я'];

var
  i,j,t: integer;
  c: array[1..2] of integer;

begin
  writeln('original text:');
  writeln(s);
  i:= 1;
  t:= 0;
  s:= s+' ';
  while i<=Length(s) do begin
    if s[i] in Lat then
      case t of
        0: begin
          t:= 1;
          j:= i
        end;
        2: t:= 3
      end
    else if s[i] in Rus then
      case t of
        0: begin
          t:= 2;
          j:= i
        end;
        1: t:= 3
      end
    else begin
      case t of
        1,2: inc(c[t]);
        3: begin
          Delete(s,j,i-j);
          Insert('error',s,j)
        end
      end;
      t:= 0
    end;
    inc(i)
  end;
  writeln('lat words: ',c[1]);
  writeln('rus words: ',c[2]);
  writeln('corrected text:');
  writeln(s);
  readln
end.

Leave a Comment

51 − = 46