Number Pattern

 import java.util.*;

public class Main{
    public static void main(String[] args){          
           //Fill your code
           Scanner sc = new Scanner(System.in);
           int n=sc.nextInt();
           int c=n-1;
           for(int i=1;i<=n;i++){
               if(i%2==0)
               System.out.println(c++);
               for(int j=1;j<=n;j++) {
                   System.out.print(i);

               }
               if(i%2!=0)
               System.out.print(c++);
               System.out.println();
           }
    }
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.