Jacob_Thomas

Untitled

Sep 7th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. import java.util.*;
  2. class Anu_Pattern
  3. {
  4.     public static void main(String []args)
  5.     {
  6.         Scanner sc=new Scanner(System.in);
  7.         int n=sc.nextInt();
  8.         int inc1=0;
  9.         boolean flag=false;
  10.         for(int x=0;x<(2*n);x++)
  11.         {
  12.             if(x<(n+1))
  13.             {
  14.                 System.out.print("@");
  15.             }
  16.             for(int y=0;y<inc1;y++)
  17.             {
  18.                 System.out.print(" ");
  19.             }
  20.             if(flag==false)
  21.             {
  22.                 if(x<(n-1))
  23.                 {
  24.                     inc1+=(n-1);
  25.                 }  
  26.                 else if(x==(n-1))
  27.                 {
  28.                     inc1+=n;
  29.                 }
  30.                 else
  31.                 {
  32.                     inc1+=1;
  33.                     flag=true;
  34.                 }
  35.             }
  36.             if(x<n)
  37.                 for(int z=0;z<n;z++)
  38.                 {
  39.                     System.out.print("*");
  40.                 }
  41.             if(x>=(n-1))
  42.             {
  43.                 System.out.print("@");
  44.             }
  45.             System.out.println();
  46.         }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment