/**from 时 代 J a v a - nowjava.com**/
public class Main {
public static void main(String args[]) throws Exception {
int row = 4;
int col = 3;
int[][] mMatrix = new int[row][col];
int r, c;
for (r = 0; r < mMatrix.length; r++) {
for (c = 0; c < mMatrix[r].length; c++) {
mMatrix[r][c] = r +c;
}
}
// printing input Matrix :
for (r = 0; r < mMatrix.length; r++) {
for (c = 0; c < mMatrix[r].length; c++) {
System.out.print(mMatrix[r][c]);
}/** 时 代 J a v a 公 众 号 提供 **/
System.out.println();
}
// transpose matrix declared
int[][] mTranpose = new int[row][col];
for (r = 0; r < mMatrix.length; r++) {
for (c = 0; c < mMatrix[r].length; c++) {
mTranpose[c][r] = mMatrix[r][c];
}
}
System.out.println("Transpose :");
for (r = 0; r < mMatrix.length; r++) {
for (c = 0; c < mMatrix[r].length; c++) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。