System.out.println("            *");
System.out.println("           * *");
System.out.println("          * * *");
System.out.println("         * * * *");
...
够简单吧 , 不知楼主是何目的,是为了考查大家的基本功,还是为了向大家提供一个展示各自奇技淫巧的题目,还是闲着无事找乐子,

解决方案 »

  1.   

    public class Test {    public static void main(String[] args) {
            final int n = 10;
            for (int i = 0; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    System.out.print(' ');
                }
                System.out.print('*');
                for (int j = 1; j <= i; ++j) {
                    System.out.print(" *");
                }
                System.out.println();
            }
        }
    }
              *
             * *
            * * *
           * * * *
          * * * * *
         * * * * * *
        * * * * * * *
       * * * * * * * *
      * * * * * * * * *
     * * * * * * * * * *
      

  2.   

    z_j() 的方法真是无话可说。
     jamesfancy()边城狂人(James Fancy) 的方法中规中矩,大部分人都会这么写。这个不是我的作业,我现在已经不用做作业了。只是想找一些巧妙的方法做一些小事。呵呵。
      

  3.   

    嗯。ntzls(三星堆)的想法有意思.....果然不愧是*
      

  4.   

    public class Star
    {
    public static void main(String args[])
    {
    int MAX = 10;
    for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX * 2-1; j++) {
    if (j >= MAX - i - 1 && j <= MAX + i - 1 && (MAX - i + j +1) % 2 == 0)
    System.out.print("*");
    else
    System.out.print(" ");
    }
    System.out.println();
    }
    }
    }
    好怀念的程序阿,只有两个for循环 :-p
      

  5.   

    三星堆说用substring可以做到。
    不过他没有写出做法。
    期待有人能写出来。
      

  6.   

    见笑,不求效率,只求少写两行代码:)
    public class Test{
    public static void main(String[] args){
    String star =  "* * * * * * * * * * * ";
    String blank = "          ";
    for(int i=1,m=star.length(),n=blank.length();i<=n;i++){
    System.out.print(blank.substring(i));
    System.out.println(star.substring(m-i*2));
    }
    }
    }
      

  7.   

    先生成一个足够长的串然后使用substring妙……
      

  8.   

    ntzls(三星堆) 兄的blank应该是这个吧..:)
    public class wonderSubstring{
    public static void main(String[] args){
    String star = "* * * * * * * * * * *";
    String blank = "          ";
    for(int i=1,m=star.length(),n=blank.length();i<=n;i++){
    System.out.print(blank.substring(i));
    System.out.println(star.substring(m-i*2));
    }
    }
    }
      

  9.   

    用一个循环,也不是不可以public class Test {
        public static void test() {
            String data[] = { " ", " *" };
            int width = 1;
            int output = 0;
            final int n = 10;
            for (int i = 1; width <= n; ++i) {
                System.out.print(data[output]);
                if (i + width == n) {
                    output = 1;
                } else if (i == n) {
                    output = 0;
                    i = 0;
                    System.out.println();
                    ++width;
                }
            }
        }    public static void main(String[] args) {
            test();
        }
    }
      

  10.   

    刚才那个有点点问题,改了一下下/*
     * @(#) Test.java
     * Create By James Fancy
     */
    package jamesfancy;public class Test {
        public static void test() {
            String data[] = { " ", " *" };
            int width = 1;
            int output = 0;
            final int n = 10;
            for (int i = 0; width <= n; ++i) {
                if (i + width == n) {
                    output = 1;
                } else if (i == n) {
                    output = 0;
                    i = -1;
                    System.out.println();
                    ++width;
                }
                if (i >= 0) {
                    System.out.print(data[output]);
                }
            }
        }    public static void main(String[] args) {
            test();
        }
    }
      

  11.   

    给你一句代码:
    System.out.println("          *\r\n         * *\r\n        * * *\r\n       * * * *\r\n      * * * * *\r\n     * * * * * *\r\n    * * * * * * *\r\n   * * * * * * * *\r\n  * * * * * * * * *\r\n * * * * * * * * * *\r\n");http://www.yi-dao.com
      

  12.   

    zhigangxie(易道模型) 
    才是最强的答案
      

  13.   

    jamesfancy()边城狂人(James Fancy) 的方法不错。
     zhigangxie(易道模型)的程序不用动脑子都可以写啦,有什么用。
      

  14.   

    public class Test1 {
        public static void main(String[] arg ) {
            int n =10;        
            char[] line = new char[n];
            StringBuffer result = new StringBuffer(((n+(n<<1)+1)*n)>>1));
            while(n>0) {
                line[--n]='*';
                result.append(line).append(line,n,line.length-n-1).append('\n');
            }
            System.out.println(result);
            
        }
    }