import java.util.Scanner; class Swastik{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter number"); int num = sc.nextInt(); for(int i=1;i<=num;i++) { for(int j=1;j<=num;j++) { if((j==1 && i<=num/2) || (j==num/2) || (i==num/2)||(i==1 && j>=num/2) || ((i==num/2 || j==num) && i>num/2) || (i==num && j<=num/2)) { System.out.print("*"); } else System.out.print(" "); } System.out.println(); } } }
0 comments:
Post a Comment