Вопрос задан 24.02.2019 в 13:13. Предмет Информатика. Спрашивает Бугаёв Сергей.

срочноСекретный замок для сейфа состоит из 10 расположенных в ряд ячеек, в которые надо вставить

игральные кубики. Но дверь открывается только в том случае, когда в любых трех соседних ячейках сумма точек на передних гранях кубиков равна 10. (Игральный кубик имеет на каждой грани от 1 до 6 точек.) Напишите программу, которая разгадывает код замка при условии, что два кубика уже вставлены в ячейки
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Буйских Варвара.
Var
  n1, n2, n3: integer;
begin
  write('Введите очки на двух первых кубиках: ');
  readln(n1, n2);
  n3 := 10 - (n1 + n2);
  writeln('Замок имеет код ', n1, n2, n3, n1, n2, n3, n1, n2, n3, n1);
end.

Тестовое решение:

Введите очки на двух первых кубиках: 3 5
Замок имеет код 3523523523


0 0
Отвечает Чигрин Аркадий.
var
  a: array [1..10] of integer;
  i: integer;
begin
  readln(a[1], a[2]);
  write('Код замка: ', a[1], ' ', a[2], ' ');
  for i := 3 to 10 do
  begin
    a[i] := 10 - (a[i - 1] + a[i - 2]);
    write(a[i], ' ');
  end;
end.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Secret Lock Code for the Safe

To write a program that can solve the secret lock code for the safe, we need to find a combination of three adjacent cells where the sum of the points on the front faces of the inserted dice is equal to 10. The dice have points ranging from 1 to 6 on each face.

Here's a Python program that can solve the secret lock code for the safe:

```python def solve_lock_code(cells): for i in range(len(cells) - 2): dice1 = cells[i] dice2 = cells[i + 1] dice3 = cells[i + 2] if sum(dice1) + sum(dice2) + sum(dice3) == 10: return i, i + 1, i + 2 return None

# Example usage: cells = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 4, 6, 1, 3, 5], [3, 1, 4, 2, 5, 6]] result = solve_lock_code(cells)

if result: print("The lock code is:", result) else: print("No valid lock code found.") ```

In this program, the `solve_lock_code` function takes a list of cells as input. Each cell is represented by a list of dice faces. The function iterates through the cells and checks if the sum of the points on the front faces of three adjacent dice is equal to 10. If a valid lock code is found, the function returns the indices of the three cells. Otherwise, it returns `None`.

In the example usage, we have a list of four cells, each containing a dice configuration. The program will search for a valid lock code among these cells. If a valid lock code is found, it will be printed; otherwise, a message indicating that no valid lock code was found will be printed.

Please note that this program assumes that the dice configurations are provided in the correct order and that there is only one valid lock code. If there are multiple valid lock codes or the dice configurations are not in the correct order, the program may not produce the desired result.

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

0 0

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

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

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