代码如下:
运行结果如下:
以下是文字版的代码:
import java.util.Scanner;
public class Test{
public static void main(String []args) {
Scanner in=new Scanner(System.in);
System.out.print("请输入数组c第一维的元素个数:");
int n=in.nextInt();
char[][] c=new char[n][];
int[] m=new int[n];
int i,k;
String s;
for(i=0;i
{
System.out.print("请输入数组c["+i+"]的元素个数:");
m[i]=in.nextInt();
c[i]=new char[m[i]];
for(k=0;k
{
System.out.print("请输入c["+i+"]["+k+"]:");
s=in.next();
c[i][k]=s.charAt(0);
}
}
in.close();
System.out.println("输入的二维数组如下:");
for(i=0;i
{for(k=0;k
{
System.out.print(c[i][k]+" ");
}
System.out.println();
}
}
}