
Вопрос задан 25.07.2020 в 12:00.
Предмет Информатика.
Спрашивает Нейман Август.
Суть программы заключается в транслитерации на другие символы. Человек выбирает что ему сделать
перевести "privet" в символы или наоборот. Как сделать эту прогу через else. Выбивает ошибки. Т.е. должно сначала выходить 1) "что вы хотите сделать: перевести мое сообщение (нажмите 1) или перевести сообщение от меня(т.е. в обычный алфавит). 2)пользователь выбирает или 1 или 2(если 1 то транслитерация из букв в символы иначе из символов в буквы) 3)Пользователь вводит буквы или цифры и ему выдает переведенный результат. Как сделать программу через else? Она работает и так, но для того, чтобы выбрать первый вариант приходится вводить цифру 1 много раз. С цифрой 2 все в порядке. Помогите пожалуйста, отдаем практически все балы. Var a1,a4, a5, a6, i :integer; Var a3, a2, b1, b2, b3 : string; begin Write ('Hello! What do you want from me? It is that what I can: 1)translate message encrypted by me(enter 1) or encrypt message inputted by me(enter 2)'); readln (a2); if a2 = '2' then writeln('enter your message'); readln(a3); for i := 1 to length(a3) do begin if a3[i]='a' then a3[i]:= '*'; if a3[i]='b' then a3[i]:= '+'; if a3[i]='c' then a3[i]:= '-'; if a3[i]='d' then a3[i]:= '='; if a3[i]='e' then a3[i]:= '!'; if a3[i]='f' then a3[i]:= '@'; if a3[i]='g' then a3[i]:= '#'; if a3[i]='h' then a3[i]:= '%'; if a3[i]='i' then a3[i]:= '&'; if a3[i]='g' then a3[i]:= ')'; if a3[i]='k' then a3[i]:= '('; if a3[i]='l' then a3[i]:= '`'; if a3[i]='m' then a3[i]:= '~'; if a3[i]='n' then a3[i]:= '^'; if a3[i]='o' then a3[i]:= '\'; if a3[i]='p' then a3[i]:= '/'; if a3[i]='q' then a3[i]:= '}'; if a3[i]='r' then a3[i]:= '{'; if a3[i]='s' then a3[i]:= ']'; if a3[i]='t' then a3[i]:= '['; if a3[i]='u' then a3[i]:= ':'; if a3[i]='v' then a3[i]:= ';'; if a3[i]='w' then a3[i]:= '>'; if a3[i]='y' then a3[i]:= '<'; if a3[i]='z' then a3[i]:= '?'; if a3[i]=' ' then a3[i]:= ' '; if a3[i]='x' then a3[i]:= ','; if a3[i]='.' then a3[i]:= '.'; write(a3[i]); end; if a2 = '1' then writeln('enter my message'); readln(a3); for i := 1 to length(a3) do begin if a3[i]='*' then a3[i]:= 'a'; if a3[i]='+' then a3[i]:= 'b'; if a3[i]='-' then a3[i]:= 'c'; if a3[i]='=' then a3[i]:= 'd'; if a3[i]='!' then a3[i]:= 'e'; if a3[i]='@' then a3[i]:= 'f'; if a3[i]='#' then a3[i]:= 'g'; if a3[i]='%' then a3[i]:= 'h'; if a3[i]='&' then a3[i]:= 'i'; if a3[i]=')' then a3[i]:= 'j'; if a3[i]='(' then a3[i]:= 'k'; if a3[i]='`' then a3[i]:= 'l'; if a3[i]='~' then a3[i]:= 'm'; if a3[i]='^' then a3[i]:= 'n'; if a3[i]='\' then a3[i]:= 'j'; if a3[i]='/' then a3[i]:= 'p'; if a3[i]='}' then a3[i]:= 'q'; if a3[i]='{' then a3[i]:= 'r'; if a3[i]=']' then a3[i]:= 's'; if a3[i]='[' then a3[i]:= 't'; if a3[i]=':' then a3[i]:= 'u'; if a3[i]=';' then a3[i]:= 'v'; if a3[i]='>' then a3[i]:= 'w'; if a3[i]='<' then a3[i]:= 'y'; if a3[i]='?' then a3[i]:= 'z'; if a3[i]=' ' then a3[i]:= ' '; if a3[i]=',' then a3[i]:= 'x'; if a3[i]='.' then a3[i]:= '.'; write(a3[i]); end; end.

Ответы на вопрос

Отвечает Аманжулов Саламат.
Const
s1='abcdefghijklmnopqrstuvwyz x.';
s2='*[email protected]#%&)(`~^\/}{][:;><? ,.';
var a:string; c:char; i:integer;
begin
Writeln ('Hello! What do you want from me? It is that what I can:');
writeln('1)translate message encrypted by me (enter 1) or encrypt message inputted by me (enter 2)');
readln (c);
if c = '2' then
begin
writeln('enter your message');
readln(a);
for i := 1 to length(a) do
if pos(a[i],s1)>0 then a[i]:=s2[pos(a[i],s1)]
end
else // if c = '1' then
begin
writeln('enter my message');
readln(a);
for i := 1 to length(a) do
if pos(a[i],s2)>0 then a[i]:=s1[pos(a[i],s2)]
end;
writeln(a);
end.
Пример:
Hello! What do you want from me? It is that what I can:
1)translate message encrypted by me (enter 1) or encrypt message inputted by me (enter 2)
2
enter your message
privet
/{&;![
s1='abcdefghijklmnopqrstuvwyz x.';
s2='*[email protected]#%&)(`~^\/}{][:;><? ,.';
var a:string; c:char; i:integer;
begin
Writeln ('Hello! What do you want from me? It is that what I can:');
writeln('1)translate message encrypted by me (enter 1) or encrypt message inputted by me (enter 2)');
readln (c);
if c = '2' then
begin
writeln('enter your message');
readln(a);
for i := 1 to length(a) do
if pos(a[i],s1)>0 then a[i]:=s2[pos(a[i],s1)]
end
else // if c = '1' then
begin
writeln('enter my message');
readln(a);
for i := 1 to length(a) do
if pos(a[i],s2)>0 then a[i]:=s1[pos(a[i],s2)]
end;
writeln(a);
end.
Пример:
Hello! What do you want from me? It is that what I can:
1)translate message encrypted by me (enter 1) or encrypt message inputted by me (enter 2)
2
enter your message
privet
/{&;


Отвечает Лаврова Анастасия.
Вам нужно добавить begin (2 штуки) после if и end закрывающий
Смотрите ссылку
http://rextester.com/WQJ56217
Смотрите ссылку
http://rextester.com/WQJ56217


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
Предметы
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili