
ABCpaskal: Дана строка символов.Определить,можно ли из символов данной строки получить слово лес???
Помогите пожалуйста)))!!!

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

s: string;
begin
readln(s);
if (Pos('л',s)>0) and (Pos('е',s)>0) and (Pos('с',s)>0) then
writeln('Можно') else writeln('Нельзя')
end.



var st: string; l, e, s: integer;
begin
readln(st);
l := pos('л', st);//Находим позицию символа л
e := pos('е', st);//Находим позицию символа е
s := pos('с', st);//Находим позицию символа с
if (l = 0) or (e = 0) or (s = 0) then writeln('Составить слово лес нельзя.'); //Если символ не был найден, то ему присваивается значение равное 0, следовательно, дальнейшее выполнение программы бессмысленно.
if (l > 0) and (e > 0) and (s > 0) then writeln('Можно составить слово: ', copy(st, l, 1) + copy(st, e, 1) + copy(st, s, 1)); //Если символ найден, ему присваивается значения, равное позиции в строке. Далее выводим на печать символы, расположенные в этих позициях.
end.
Еще раз повторюсь, решение Yuliagal верное, и самое короткое.



Can the word "лес" be formed from the characters in a given string?
To determine if the word "лес" can be formed from the characters in a given string, we need to check if the string contains the necessary characters in the correct order.
Here's a step-by-step approach to solving this problem:
1. Identify the necessary characters: The word "лес" consists of the characters 'л', 'е', and 'с'.
2. Check if the string contains all the necessary characters: Iterate through each character in the string and check if it matches any of the necessary characters. Keep track of the order of the characters found.
3. Verify the order of the characters: Once all the necessary characters are found, check if they appear in the correct order. In this case, the order should be 'л', 'е', and 'с'.
4. Return the result: If all the necessary characters are found in the correct order, return "Yes, the word 'лес' can be formed from the characters in the given string." Otherwise, return "No, the word 'лес' cannot be formed from the characters in the given string."
Let's apply this approach to the given string:
Given string: ABCpaskal
1. Necessary characters: 'л', 'е', 'с' 2. Iterating through the given string, we find the characters 'a', 's', and 'k'. None of these characters match the necessary characters. 3. Since none of the necessary characters are found, we cannot form the word "лес" from the given string.
Therefore, the answer is: No, the word 'лес' cannot be formed from the characters in the given string.
Please let me know if you have any further questions!


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