菱形

package hello;

public class sanjiaoxing1 {

    public static void main(String[] args) {
         //public static void main(String[] args) {
              for (int b = 1; b <= 5; b++) {  //上部分
               for (int c = 5 - b; c >= 0; c--) {
                System.out.print(" ");
               }
               for (int a = 1; a <= 2 * b - 1; a++) {
                System.out.print("*");
               }
               System.out.println();
              }
              for (int d = 4; d >= 1; d--) {  //下部分
               for (int c = 5 - d; c >= 0; c--) {
                System.out.print(" ");
               }
               for (int a = 2 * d - 1; a >= 1; a--) {
                System.out.print("*");
               }
               System.out.println();
              }
             }
            }
原文地址:https://www.cnblogs.com/php111/p/5020603.html