Skip to content · ⁨コンテンツへスキップ⁩

Transpose a grid · ⁨グリッドの転置⁩

English

Transpose a grid

Swap the rows and columns of a grid, as if you reflected a table across its diagonal.

grid[r][c] is the item in row r and column c. The new grid has one row for each column of the old one, so loop over the column numbers first, and inside that loop collect row[col] from every row.

日本語

グリッドの転置

グリッドの行と列を入れ替えます。これは、表を対角線に対して鏡像反射したかのように振る舞います。

grid[r][c] は行 r と列 c の項目です。新しいグリッドは古いグリッドの各列に対応する行を持つため、まず列番号をループで処理し、その内部ループで各行から row[col] を収集します。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP