Java练习题01
问题:
利用二维非矩阵数组输出下面的数字
0
1 2
2 3 4
3 4 5 6
代码:
public class Page98{
public static void main(String args[]){
int NumArray[][] = new int [4][];
NumArray[0]=new int[]{0};
NumArray[1]=new int[]{1,2};
NumArray[2]=new int[]{2,3,4};
NumArray[3]=new int[]{3,4,5,6};
for(int i = 0; i < NumArray.length; i++){
for(int j = 0; j < NumArray[i].length; j++){
System.out.print(" ");
System.out.print(NumArray[i][j]);
}
System.out.println(" ");
}
}
};