【java】for循环输出数字金字塔

输出下列数字金字塔。
    1
  121
 12321
1234321


 1 public class deng {
 2 public static void main(String args[])
 3 {
 4     int n,i,k,j;                    
 5     for(n=1; n<=4; n++) //n在最外层控制行数 
 6     {
 7         for(i=1; i<=4-n;i++)
 8             System.out.print(" ");
 9         for(k=1; k<=n; k++)
10             System.out.print(k);
11         for(j=n-1; j>=1;j--)
12             System.out.print(j);
13         
14         System.out.print("
");
15         
16     }
17 }
18 }
原文地址:https://www.cnblogs.com/isdxh/p/3623867.html