Вопрос задан 07.05.2019 в 18:36. Предмет Информатика. Спрашивает Махметов Ильяс.

Каждый солнечный день улитка сидящая на дереве поднимается вверх на 2 см а в пасмурный день

опускается на 10 см. в начале недели улитка находилась на а см от земли и на в метровом дереве. Имеются 30 массив, содержащий сведения о том был ли соответствующий день пасмурным. Определить место положения улитки к концу 30 дня. паскаль
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Гелик Ангелина.
Var day: array[1..30] of boolean;
i, pos, tree_height : integer;
Begin
  readln(pos, tree_height);

  for i := 1 to 30 do
    day[i] := (random(100) > 30);

  for i := 1 to 30 do begin
    if day[i] then pos := pos + 2
    else pos := pos - 10;

    if pos > tree_height then pos := tree_height;
    if pos < 0 then pos := 0;

    writeln('День ', i:2, '(', day[i]:5,') pos = ',pos);
  end;

  writeln(pos);
End.


0 0
Отвечает Гашишев Дмитрий.
Program Ulitka;
Var SunnyDay: Array [1..30] Of Boolean;
a, b, c, i: Integer;
Begin
WriteLn('a = ');
ReadLn(a);
WriteLn('b = ');
ReadLn(b);
b := b * 100;
Randomize;
For i := 1 To 30 Do
Begin      
If Random(2) = 1 Then
SunnyDay[i] := True
Else
SunnyDay[i] := False;
End;
For i := 1 To 30 Do
Begin  
If SunnyDay[i] = True
ThenBegin    
a := a + 2;    
If a > b Then    
a := b;  
End  
Else  
Begin   
a := a - 10;    
If a < 0 Then    
a := 0;  End;  
End; WriteLn('Дни месяца были таковы:');
For i := 1 To 30 Do
Begin
If SunnyDay[i] = True Then
WriteLn(i, '. Солнечный')
Else
WriteLn(i, '. Пасмурный')
End;
WriteLn('К концу 30 дня местоположение улитки равно ', a, ' см над землей');
End.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Problem Analysis

We are given the following information: - On a sunny day, a snail sitting on a tree moves up by 2 cm. - On a cloudy day, the snail moves down by 10 cm. - At the beginning of the week, the snail is at a distance of 'a' cm from the ground on a 1-meter tree. - We have an array of 30 elements indicating whether each day was cloudy or not.

We need to determine the final position of the snail after 30 days.

Solution

To solve this problem, we can iterate through the array of 30 elements and update the snail's position based on whether the day was cloudy or sunny.

Let's assume the initial position of the snail is 'a' cm from the ground. We can initialize a variable `position` with the value of 'a'. Then, for each day in the array, we can check if it was cloudy or sunny. If it was sunny, we add 2 cm to the `position`. If it was cloudy, we subtract 10 cm from the `position`.

After iterating through all the days, the final position of the snail will be the value of `position`.

Pseudocode

Here's the pseudocode for the solution:

``` position = a for each day in the array: if day is sunny: position = position + 2 else: position = position - 10

final_position = position ```

Implementation

Now let's implement the solution in Pascal:

```pascal program SnailPosition;

var a, final_position: integer; days: array[1..30] of boolean; i: integer;

begin a := 100; // initial position of the snail in cm // Initialize the array with the information about cloudy or sunny days // (true for cloudy, false for sunny) days[1] := true; days[2] := false; // ... days[30] := true;

// Calculate the final position of the snail final_position := a; for i := 1 to 30 do begin if days[i] then final_position := final_position - 10 else final_position := final_position + 2; end;

writeln('The final position of the snail after 30 days is ', final_position, ' cm.'); end. ```

Example Calculation

Let's assume the initial position of the snail is 100 cm from the ground on a 1-meter tree. We have the following array of 30 elements indicating whether each day was cloudy or not:

``` [true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true] ```

Using the pseudocode and the given array, we can calculate the final position of the snail:

``` position = 100

Day 1: Cloudy (subtract 10 cm) position = 100 - 10 = 90

Day 2: Sunny (add 2 cm) position = 90 + 2 = 92

Day 3: Cloudy (subtract 10 cm) position = 92 - 10 = 82

...

Day 30: Sunny (add 2 cm) position = 72 + 2 = 74

Final position = 74 cm ```

Therefore, the final position of the snail after 30 days is 74 cm from the ground.

Note: The values used in this example are for illustration purposes only. You can replace them with your own values when implementing the solution.

0 0

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

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

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