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