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