public void printAngle(int n)
{
for(int i=1;i<n+1;i++)
{
for(int j=i;j<n+1;j++)
System.out.print(" ");
for(int k=1;k<i+1;k++)
System.out.print(k);
for(int m=i-1;m>0;m--)
System.out.print(m);
System.out.println();
}
}

解决方案 »

  1.   

    ---------
    二楼的程序能运行
    -----------printAngle(9);Result:
              1
             121
            12321
           1234321
          123454321
         12345654321
        1234567654321
       123456787654321
      12345678987654321
      

  2.   

    public static void main(String[] args) {
    int i = 0;
    boolean b = false;
    for (i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9 - i; j++)
    System.out.print(" ");
    for (int j = 1, change = i - 1; j <= 2 * i - 1; j++) {
    if (j <= i)
    System.out.print(j);
    else {
    System.out.print(change);
    change--;
    } }
    for (int j = 1; j <= 9 - i; j++)
    System.out.print(" "); System.out.println(""); } }
      

  3.   

    public static void main(String args[]){
            for(int i=1;i<10;i++){
                for(int k=10-i;k>0;k--)
                    System.out.print(" ");
                for(int j=1;j<i+1;j++){
                    System.out.print(j);
                }
                for(int j=i-1;j>=1;j--)
                    System.out.print(j);
                System.out.println("");
            }
        }
      

  4.   

    这么多人都会啊,基础题.学习啊,从工作以来,都是写一些没有意义的代码,这样的代码虽然每本书上几乎都有,20行step,可是意义不必写一千字符串差
      

  5.   

    我写了一个只有三个for语句的:
    class For {

    public void printAngle(int n)
    {
    for(int i=1;i<n;i++)
    {
    for(int j=n-1;j-i>0;j--)
    {
    System.out.print(" ");
    }
    for(int k= -(i-1);Math.abs(k)<i;k++)
    {
    System.out.print(i-Math.abs(k));
    }
    System.out.println();
    }
    }
    public static void main(String[] args) {

    new For().printAngle(10);
    }
    }
      

  6.   

    public class AnglePrinter { public static void main(String[] args) {
    System.out.println("---printAngle(9)");
    printAngle(9);

    }

    private static void printAngle(int n){
    for(int i=1; i <= n; i ++){
    int j = 1;
    for(j=1; j <= i; j ++){
    System.out.print(j);
    }
    for(j-=2;j >= 1; j --){
    System.out.print(j);
    }
    System.out.println();
    }
    }}
      

  7.   

    public class ManyNumber{
     public static void main(String[] args)
     {
        int m,c,j=16,n=9;    for(m=1;m<=n;m++)
        {
        for(int i=j;i>0;i--)
          System.out.print(" ");
        for(c=1;c<=m;c++)
        {
         System.out.print(" "+c);
         }
        for(c-=2;c>0;c--){
         System.out.print(" "+c);
        }
        System.out.println();
        j-=2;
       }
       }
       }各个结构都是分开的
    适合新手阅读