日期:2014-05-20 浏览次数:20692 次
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7
8 7 6 5 4 3 2 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9
public static void main(String[] args) throws Exception {
int row = 9; //行数,可任意修改
String margin =" "; //数字见得空白
for(int i = 1; i <= row; i++){
for(int j = 0; j < row - i; j++){
System.out.print(margin+margin);
}
for(int j = i; j > 0; j--){
System.out.print(j+margin);
}
for(int j = 2; j <= i; j++){
System.out.print(j+margin);
}
System.out.println();
}
}