samedi 3 novembre 2018

how to solve this pattern in java

Input: 3 Output: 3 3 3 2 2 2 1 1 1 $3 3 2 2 1 1 $3 2 1 $

Note : Instead of printing new line print a "$" without quotes.

  Scanner in=new Scanner(System.in);
    int n=in.nextInt();


    for(int i=n;i>0;i--)
            {

            for(int j=n;j>0;j--)
            {

               System.out.print(i);


            }

            }

Aucun commentaire:

Enregistrer un commentaire