Вопрос задан 24.02.2019 в 03:39. Предмет Информатика. Спрашивает Алиев Миша.

Срочно! В Паскале ABC.Дано слово S1 получить слово S2 образованное буквами слова S1, стоящими на

четных местах.Решить циклом с параметром.Заранее спасибо.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Перелыгин Савватий.

Program Slova;

Uses Crt;

var s1,s2:string;

 

        i,k:integer;

begin

     clrscr;

     s2:='';

     write('Введите слово: ');

     readln(s1);

     k:=length(s1);

     for i:=1 to k do

         if (i mod 2)=0 then s2:=s2+s1[i];    

    writeln('Полученное слово:',s2); 

    readkey;

 

end. 

 

 

 

 

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

Problem Statement

You need to write a Pascal program that takes a word, S1, as input and generates a new word, S2, consisting of the letters from S1 that are in even positions. You should solve this problem using a loop with a parameter.

Solution

To solve this problem, you can follow these steps:

1. Declare two variables, `S1` and `S2`, to store the input word and the resulting word, respectively. 2. Read the input word, `S1`, from the user. 3. Initialize an empty string, `S2`, to store the letters from `S1` that are in even positions. 4. Use a loop with a parameter to iterate over the characters of `S1`. 5. Inside the loop, check if the current position is even. If it is, append the corresponding letter to `S2`. 6. After the loop finishes, output the resulting word, `S2`.

Here's an example implementation of the solution in Pascal:

```pascal program ExtractEvenLetters;

var S1, S2: string; i: integer;

begin // Read the input word write('Enter a word: '); readln(S1);

// Extract letters from even positions S2 := ''; for i := 1 to length(S1) do begin if i mod 2 = 0 then S2 := S2 + S1[i]; end;

// Output the resulting word writeln('Result: ', S2);

end. ```

You can run this program and test it with different input words to see the desired output.

Note: The program assumes that the first position in the word is considered odd.

I hope this helps! Let me know if you have any further questions.

0 0

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

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

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