package com.netnew;
public class Tower {
public static void main(String[] args) {
printTower(9);
}
public static void printTower(int num){
int line=num;
int i,j,k,a,b;
for(i=1;i<=line;i++){
for(j=8;j>=i;j--){
System.out.print(" ");
}
for(k=1;k<=(2*i-1);k++)
{
for(a=1;a<=line;a++)
{
if(k<=i&&a<=i)
System.out.print(a);
}
for(b=i-1;b>=1;b--)
{
System.out.print(b);
}
break;
}
System.out.println(" ");
}
}
}
阅读(231) | 评论(0) | 转发(0) |