Вопрос задан 20.02.2019 в 23:17. Предмет Информатика. Спрашивает Авраменко Богдан.

Составьте программу позволяющую удвоить каждый символ заданной строки и вывести полученную строку

на экран
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Мухохин Никита.
Var a,b:string;
i: integer;
begin
write('Введите строку: '); readln(a);
b:='';
for i:= 1 to length(a) do b:=b+a[i]+a[i];
write('Новая строка: ',b);
end.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Double Each Character in a String

Here's a program in Python that allows you to double each character in a given string and then prints the resulting string:

```python def double_characters(string): doubled_string = '' for char in string: doubled_string += char * 2 return doubled_string

input_string = input("Enter a string: ") result = double_characters(input_string) print("Doubled string:", result) ```

Explanation: 1. The `double_characters` function takes a string as input. 2. It initializes an empty string `doubled_string` to store the doubled characters. 3. It iterates over each character in the input string using a `for` loop. 4. For each character, it appends the character twice to the `doubled_string`. 5. Finally, it returns the `doubled_string`. 6. The program prompts the user to enter a string using the `input` function. 7. It calls the `double_characters` function with the input string as an argument and stores the result in the `result` variable. 8. It prints the doubled string by using the `print` function.

Example: Suppose you enter the string "Hello" as input. The program will double each character in the string and print the result as "HHeelllloo".

Please note that this program is written in Python. If you want to implement it in a different programming language, the syntax and approach may vary.

Let me know if you need any further assistance!

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос