如何交换阵列元素到阵列从一个柱状转移进行状再presentation [英] how to swap array-elements to transfer the array from a column-like into a row-like representation

查看:137
本文介绍了如何交换阵列元素到阵列从一个柱状转移进行状再presentation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:数组

a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3

下表重新presents

represents following table

a1, b1, c1, d1
a2, b2, c2, d2
a3, b3, c3, d3

现在我喜欢把数组转换成以下形式

now i like to bring the array into following form

a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3

是否一个算法存在,这需要在阵列(从第一形式),并在表的尺寸作为输入参数并且传送阵列到第二形式? 我thougt的算法并不需要分配更多的内存,而不是我想应该可以做的工作与元素交换操作。

Does an algorithm exist, which takes the array (from the first form) and the dimensions of the table as input arguments and which transfers the array into the second form? I thougt of an algorithm which doesn't need to allocate additional memory, instead i think it should be possible to do the job with element-swap operations.

推荐答案

你要找的期限为的就地矩阵转置的,而这里的的实施

The term you're looking for is in-place matrix transpose, and here's an implementation.

这篇关于如何交换阵列元素到阵列从一个柱状转移进行状再presentation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆