Создать программу, которая при вводе кодировке азбукой Морзе переводит точки и тире в нормальные буквы- Pascal(Паскаль)

program Katia11;

uses crt;

var
  s, s2: string;
  i, j, j2, l, r: integer;

begin
  clrscr;
  writeln('Введите кодировку: ');
  readln(s);
  l := 0;
  r := 0;
  for i := 1 to length(s) + 1 do { вот тут +1 }
  begin
    if (s[i] = ' ') or (i = length(s) + 1) then { вот тут +1 }
    begin
      r := i;
      s2 := copy(s, l + 1, r - l - 1); { вот тут -1 }
      if s2 = '.-' then
        s2 := 'А';
      if s2 = '-...' then
        s2 := 'Б';
      if s2 = '.--' then
        s2 := 'В';
      if s2 = '--.' then
        s2 := 'Г';
      if s2 = '-..' then
        s2 := 'Д';
      if s2 = '.' then
        s2 := 'Е';
      if s2 = '...-' then
        s2 := 'Ж';
      (и так далее буквы) if s2 = '--..' then s2 := 'з';
      if s2 = '..' then
        s2 := 'к';
      if s2 = '.---' then
        s2 := 'л';
      if s2 = '-.-' then
        s2 := 'и';
      if s2 = '.-..' then
        s2 := 'п';
      if s2 = '--' then
        s2 := 'о';
      if s2 = '-.' then
        s2 := 'м';
      if s2 = '---' then
        s2 := 'Д';
      if s2 = '.--.' then
        s2 := 'Е';
      if s2 = '.-.' then
        s2 := 'Й';
      if s2 = '...' then
        s2 := 'ж';
      if s2 = '-' then
        s2 := 'Ж';
      if s2 = '..-' then
        s2 := 'ф';
      if s2 = '..-.' then
        s2 := 'ц';
      if s2 = '....' then
        s2 := 'т';
      if s2 = '-.-.' then
        s2 := 'ы';
      if s2 = '---.' then
        s2 := 'щ';
      if s2 = '----' then
        s2 := 'я';
      if s2 = '--.-' then
        s2 := 'Ц';
      if s2 = '-..-' then
        s2 := 'Ь';
      if s2 = '-.--' then
        s2 := 'ў';
      if s2 = '-..-' then
        s2 := 'Ј';
      if s2 = '..-.' then
        s2 := 'Ґ';
      if s2 = '..--' then
        s2 := '₧';
      if s2 = '.-.-' then
        s2 := 'ƒ';
      write(s2);
      l := i;
    end;
  end;
  readln;

end.

Leave a Comment

62 − 56 =