Вопрос задан 15.09.2018 в 12:45. Предмет Информатика. Спрашивает Крашенинин Илья.

Var k, m, day: integer; Dat: array[1...10] of integer; Begin Dat[1] := 2; Dat[2] := 2; Dat[3] :=

3; Dat[4] := 3; Dat[5] := 2; Dat[6] := 2; Dat[7] := 5; Dat[8] := 5; Dat[9] := 6; Dat[10] := 6; day:=1; m := Dat[1]; for k := 2 to 10 do if Dat[k] =< m then begin m:= Dat[k]; day := k; end; write(day); End. Ответ равен двум, если нет объясните почему?
0 0
Перейти к ответам

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

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

Code Explanation

The given code is written in an unspecified programming language. It declares several variables and initializes an array called `Dat` with 10 integer elements. It then assigns values to the elements of `Dat` and performs some calculations to determine the value of the variable `day`. Finally, it outputs the value of `day`.

Let's break down the code step by step:

1. Variable Declaration: - `Var k, m, day: integer;` declares three variables: `k`, `m`, and `day`, all of type `integer`.

2. Array Initialization: - `Dat: array[1...10] of integer;` declares an array called `Dat` with 10 elements, each of type `integer`.

3. Assigning Values to Array Elements: - `Dat[1] := 2;` assigns the value 2 to the first element of `Dat`. - `Dat[2] := 2;` assigns the value 2 to the second element of `Dat`. - `Dat[3] := 3;` assigns the value 3 to the third element of `Dat`. - `Dat[4] := 3;` assigns the value 3 to the fourth element of `Dat`. - `Dat[5] := 2;` assigns the value 2 to the fifth element of `Dat`. - `Dat[6] := 2;` assigns the value 2 to the sixth element of `Dat`. - `Dat[7] := 5;` assigns the value 5 to the seventh element of `Dat`. - `Dat[8] := 5;` assigns the value 5 to the eighth element of `Dat`. - `Dat[9] := 6;` assigns the value 6 to the ninth element of `Dat`. - `Dat[10] := 6;` assigns the value 6 to the tenth element of `Dat`.

4. Variable Initialization: - `day := 1;` initializes the variable `day` with the value 1. - `m := Dat[1];` initializes the variable `m` with the value of the first element of `Dat`, which is 2.

5. Loop and Condition: - `for k := 2 to 10 do` starts a loop that iterates from 2 to 10 (inclusive). - `if Dat[k] <= m then` checks if the value of the current element `Dat[k]` is less than or equal to the value of `m`. - If the condition is true, the code inside the `begin` and `end` block is executed. - Inside the block, the value of `m` is updated to the value of `Dat[k]`, and the value of `day` is updated to the current value of `k`.

6. Output: - `write(day);` outputs the value of the variable `day`.

Explanation of the Output

Based on the given code, the output will be 2. This is because the code iterates through the elements of the `Dat` array starting from the second element (`k := 2`) and checks if each element is less than or equal to the current value of `m`. If it is, the value of `m` is updated, and the value of `day` is updated to the current value of `k`.

In this case, the first element of `Dat` is 2, and the value of `m` is initially set to 2. When the loop reaches the second element (`Dat[2]`), which is also 2, the condition `Dat[k] <= m` is true, and the values of `m` and `day` are updated to 2 and 2, respectively. Since there are no other elements in `Dat` that are less than or equal to 2, the loop ends, and the final value of `day` is 2.

Therefore, the output of the code is 2.

0 0

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

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

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