Send me the program for below output in java

0

 Send me the program for below output 

Send me the program for below output In JAVA GeeksCodes


             0

           101

          21012

        3210123

      432101234

     54321012345

Code :- 

public class Pattern1 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System. in);

        int num = sc.nextInt();


        int count = 5;

        boolean flag = false;


        for (int i = 0; i <= num; i++) {

            for (int j = 0; j <= 2*num; j++) {

                if(count == 0) {

                    flag = true;

                }

                if(count <= i) {

                    System.out.print(count + " ");

                } else {

                    System.out.print("  ");

                }

                if(flag) {

                    count++;

                } else {

                    count--;

                }

            }

            System.out.println();

            count = 5;

            flag = false;


        }

    }

}

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates