Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. public class Alpro1
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         int n = 5;
  6.  
  7.         /* NOMOR 1 */
  8.         for(int i=0;i<=n;i++)
  9.         {
  10.             for(int j=n;j>i;j--)
  11.             {
  12.                 System.out.print("*");
  13.             }
  14.  
  15.             System.out.println();
  16.         }
  17.  
  18.         /* NOMOR 2 */
  19.         for(int i=0;i<n;i++)
  20.         {
  21.             for(int j=0;j<=i;j++)
  22.             {
  23.                 System.out.print("*");
  24.             }
  25.  
  26.             System.out.println();
  27.         }
  28.  
  29.         for(int i=0;i<n-1;i++)
  30.         {
  31.             for(int j=n-1;j>i;j--)
  32.             {
  33.                 System.out.print("*");
  34.             }
  35.  
  36.             System.out.println();
  37.         }
  38.  
  39.         /* NOMOR 3 */
  40.         for(int i=0;i<=n;i++)
  41.         {
  42.             for(int j=0;j<=i;j++)
  43.             {
  44.                 System.out.print("-");
  45.  
  46.                 if(j == i)
  47.                 {
  48.                     System.out.print("+");
  49.                 }
  50.             }
  51.  
  52.             System.out.println();
  53.         }
  54.  
  55.         for(int i=0;i<n;i++)
  56.         {
  57.             for(int j=n-1;j>=i;j--)
  58.             {
  59.                 System.out.print("-");
  60.  
  61.                 if(j == i)
  62.                 {
  63.                     System.out.print("+");
  64.                 }
  65.             }
  66.  
  67.             System.out.println();
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement