IOM 2021, Блиц — Задача 32
The Blitz-contest of IOM-2021
Условие
What is the output of the following code fragment?
![Python code listing (printed as an image), 17 lines: n = 3; matrix = [[0 for i in range(n)] for j in range(n)]; cell, turn = 1, 0; while cell <= n * n: four for-loops over range(turn, n - turn), range(1 + turn, n - turn), range(n - 2 - turn, turn - 1, -1) and range(n - 2 - turn, turn, -1) assign cell to matrix[turn][i], matrix[i][n - 1 - turn], matrix[n - 1 - turn][i] and matrix[i][turn] respectively, each time with cell = cell + 1; then turn = turn + 1. Finally, for i in range(0, n) and for j in range(0, n), print(matrix[i][j], end = a space), with print() after each row.](https://pub-43290baaaff14857b5dd59610ea438c7.r2.dev/problems/iom-2021-blitz-tasks-eng/p32-fig1-v2.png)
| A) | B) | C) | D) | E) |
|---|---|---|---|---|
| 1 2 3 | 1 2 3 | 1 2 3 | 1 1 1 | 1 2 3 |
| 8 0 4 | 1 2 3 | 2 0 4 | 2 2 2 | 8 9 4 |
| 7 6 5 | 1 2 3 | 3 4 5 | 3 3 3 | 7 6 5 |
- A
- B
- C
- D
- E
Отговори
E
Answer key: E.
Решение
Informatics(10). Answer: E
Оригинал в Архива: iom-2021-blitz-tasks-eng.pdf · официални решения: iom-2021-blitz-answers-eng.pdf