Print Number Star Square Pattern type 6

2 comments on “Print Number Star Square Pattern type 6”


  • deepanshusaxena1803

    import java.util.*;
    public class Main{
    public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    System.out.println(“Enter the number of rows:-“);
    int r=sc.nextInt();
    int x=0,y=0,a=0,b=0;
    for(int i=0;i<r;i++){
    if(i%2==0){
    a=a+r;
    x=a;
    for(int j=0;j<r-1;j++){
    System.out.print(x+"*");
    –x;
    }
    System.out.println(x);
    }
    else{
    b=a+2*r;
    y=b;
    for(int j=0;j<r-1;j++){
    System.out.print(y+"*");
    –y;
    }
    System.out.println(y);
    }
    }
    }
    }


  • Fayaz

    class Pattern {
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);
    int n,i,j,a=4,t;
    System.out.print(“Enter N value:”);
    n= sc.nextInt();
    for(i=1;i<=n;i++)
    {
    if(i%2==0)
    {
    a=a+3*n;
    for(j=1;j<n;j++)
    {
    System.out.print((a–)+"*");
    }
    System.out.println(a–);
    }
    else
    {

    for(j=1;j<n;j++)
    {
    System.out.print((a–)+"*");
    }
    System.out.println(a–);
    }
    }
    }
    }