Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Anu_Pattern
- {
- public static void main(String []args)
- {
- Scanner sc=new Scanner(System.in);
- int n=sc.nextInt();
- int inc1=0;
- boolean flag=false;
- for(int x=0;x<(2*n);x++)
- {
- if(x<(n+1))
- {
- System.out.print("@");
- }
- for(int y=0;y<inc1;y++)
- {
- System.out.print(" ");
- }
- if(flag==false)
- {
- if(x<(n-1))
- {
- inc1+=(n-1);
- }
- else if(x==(n-1))
- {
- inc1+=n;
- }
- else
- {
- inc1+=1;
- flag=true;
- }
- }
- if(x<n)
- for(int z=0;z<n;z++)
- {
- System.out.print("*");
- }
- if(x>=(n-1))
- {
- System.out.print("@");
- }
- System.out.println();
- }
- }
- }
Add Comment
Please, Sign In to add comment