第1个回答 2012-10-09
package test;
public class PrintNum {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num=1;
int a[][]=new int[4][4];
int m=0,n=0;
while(m<4&&n<4){
m=0;
while(m<=n){
a[m][n]=num++;
m++;
}
n++;
}
for(int i=0;i<4;i++){
for(int y=0;y<4;y++){
if(a[i][y]!=0){
System.out.print(a[i][y]);
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}