还有以下的条件:将上面的程序分别改成用while循环语句和do-while循环语句实现
万分感谢!

解决方案 »

  1.   

    这不是很简单.
    public static void main(String[] args) throws Exception {
            int i, j;
            i = 0;
            while (i < 3) {
                j = 3 - i;
                while (j > 0) {
                    System.out.print(" ");
                    j--;
                }
                j = 0;
                while (j < 2 * i) {
                    System.out.print("*");
                    j++;
                }
                System.out.println("*");
                i++;
            }
            i = 0;
            while (i < 3) {
                System.out.print("*");
                i++;
            }
            System.out.print("+");
            i = 0;
            while (i < 2) {
                System.out.print("*");
                i++;
            }
            System.out.println("*");
            i = 0;
            while (i < 3) {
                j = i + 1;
                while (j > 0) {
                    System.out.print(" ");
                    j--;
                }
                j = 4 - 2 * i;
                while ( j > 0) {
                    System.out.print("*");
                    j--;
                }
                System.out.println("*");
                i++;
            }
        }
      

  2.   

    public static void main(String[] args) throws Exception {
            int i, j;
            i = 0;
            do {
                j = 3 - i;
                do {
                    System.out.print(" ");
                    j--;
                }
                while (j > 0);
                j = 0;
                do {
                    System.out.print("*");
                    j++;
                }
                while (j < 2 * i);
                if (i != 0)
                    System.out.println("*");
                else
                    System.out.println();
                i++;
            }
            while (i < 3);
            i = 0;
            do {
                System.out.print("*");
                i++;
            }
            while (i < 3);
            System.out.print("+");
            i = 0;
            do {
                System.out.print("*");
                i++;
            }
            while (i < 2);
            System.out.println("*");
            i = 0;
            do {
                j = i + 1;
                do {
                    System.out.print(" ");
                    j--;
                }
                while (j > 0);
                j = 4 - 2 * i;
                do {
                    System.out.print("*");
                    j--;
                }
                while ( j > 0);
                if (i != 2)
                    System.out.println("*");
                else
                    System.out.println();
                i++;
            }
            while (i < 3);
        }