• 打印菱形


     1 package lingxing;
     2 
     3 public class YangHuiSanJiao {
     4     public static void main(String args[])
     5     {
     6         for(int k=0;k<=2;k++)
     7         {
     8 
     9         for(int i=0;i<10;i++)
    10         {
    11             for(int j=0;j<10-i;j++)
    12             {
    13                 System.out.print("   ");
    14             }
    15             for(int j=0;j<=i;j++)
    16             {
    17                 System.out.print("   *  ");
    18             }
    19             System.out.println();
    20         }
    21     for(int i=0;i<10;i++)
    22     {
    23         for(int j=0;j<=i;j++)
    24         {
    25             System.out.print("   ");
    26         }
    27         for(int j=0;j<10-i;j++)
    28         {
    29             System.out.print("   *  ");
    30         }
    31         System.out.println();
    32     }
    33 }
    34         
    35 }
    36 }

     三行三列9个菱形

     1 package lingxing;
     2 
     3 public class YangHuiSanJiao {
     4     public static void main(String args[])
     5     {
     6         for(int k=0;k<=2;k++)
     7         {
     8 
     9         for(int i=0;i<10;i++)
    10         {
    11             for(int m=0;m<3;m++) {
    12             for(int j=0;j<10-i;j++)
    13             {
    14                 System.out.print("   ");
    15             }
    16             for(int j=0;j<=i;j++)
    17             {
    18                 System.out.print("   *  ");
    19             }
    20             for(int j=0;j<10-i;j++)
    21             {
    22                 System.out.print("   ");
    23             }
    24             }
    25             System.out.println();
    26         }
    27     for(int i=0;i<10;i++)
    28     {
    29         for(int m=0;m<3;m++) {
    30         for(int j=0;j<=i;j++)
    31         {
    32             System.out.print("   ");
    33         }
    34         for(int j=0;j<10-i;j++)
    35         {
    36             System.out.print("   *  ");
    37         }
    38         for(int j=0;j<=i;j++)
    39         {
    40             System.out.print("   ");
    41         }
    42         }
    43         System.out.println();
    44     }
    45 }
    46         
    47 }
    48 }
  • 相关阅读:
    112. Path Sum
    66. Plus One
    258. Add Digits
    268. Missing Number
    275. H-Index II
    274. H-Index
    264. Ugly Number II
    263. Ugly Number
    199. Binary Tree Right Side View
    222. Count Complete Tree Nodes
  • 原文地址:https://www.cnblogs.com/liugangjiayou/p/10745042.html
Copyright © 2020-2023  润新知