1
  *
 ***
*****
 ***
  *2
  *
 ***
*****3
****
 ****
  ****

解决方案 »

  1.   

    第一个稍微复杂一些, 我写了一个:public class PrintDiamond {
        static int unit = 5;
        public static void main(String[] args) {
            if(args.length > 0) unit = Integer.parseInt(args[0]);
            if(unit < 0 || unit > 80 || unit % 2 != 1) {
                System.out.println("请输入0-80之间的奇数。");
                return;
            }
            print();
        }
        static void print() {
            int i, j;
            int spaces, stars;
            for(i = 0; i < unit; i++) {            //计算每行要打印的空格个数和星号个数
                stars = i <= unit / 2 ? i * 2 + 1 : (unit - i) * 2 - 1;
                spaces = (unit - stars) / 2;            //打印空格
                for(j = 0; j < spaces; j++)
                    System.out.print(" ");            //打印星号
                for(j = 0; j < stars; j++)
                    System.out.print("*");            System.out.print("\n");        }
        }
    } ///:~可以自定义尺寸的, 运行时用java PrintDiamond <尺寸>其它两个比较简单, 楼主自己写吧.
      

  2.   

    第二个:
    public class San{
      public static void main(String arg[]){
        int i,n,l,j;
        for(i=3,j=1;i>0;i--,j=j+2){
        for(n=0;n<i;n++){
          System.out.print(" ");
        }
        for(l=0;l<j;l++){
         System.out.print("*");
        }
        System.out.println();
        }
    }
    }
      

  3.   

    第3个:
    public class San{
      public static void main(String arg[]){
        int i,n,l,j;
        for(i=3,j=0;i>0;i--,j++){
        for(n=0;n<j;n++){
          System.out.print(" ");
      }
       for(l=0;l<4;l++){
         System.out.print("*");
        }
        System.out.println();
        }
    }
    }
      

  4.   

    都太复杂了,直接
    System.out.println("  *\n ***\n*****\n ***\n  *");就能打印第一个,
    后面的也同样哈.