1. 互换二维数组的行列。要求数组的行数、列数以及各元素均从键盘输入;输出互换前数组内容和互换后数组内容。(要求循环输入进行测试)
package com.mingrisoft;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
public class MyApp{
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
while(scan.hasNextInt())
{
int m=scan.nextInt();
int n=scan.nextInt();
int i,j,k;
int array[][]=new int[m][n];
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
array[i][j]=scan.nextInt();
}
}
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
System.out.print(array[i][j]+" ");
}
System.out.println();
}
System.out.println();
for (i=0;i<n;i++)
{
for (j=0;j<m;j++)
{
System.out.print(array[j][i]+" ");
}
System.out.println();
}
}
}
}