Page 416 - Computer science 868 Class 12
P. 416

8         }
                9         void call()

                10        {
                11          display(n, n, "");
                12        }

                13        void display(int a, int g, String s) {

                14          if (a == 0) // base case
                15           {    System.out.println(s); }
                16

                17           for (int i = Math.min(g, a); i >= 1; i--) {
                18            display(a-i, i, s + " " + i); // recursive method call

                19          }
                20        }

                21        public static void main() {
                22          Addup ob=new Addup(); // object creation

                23          ob.accept();
                24          ob.call();

                25        }
                26      }

              The output of the preceding program is as follows:







































                414414  Touchpad Computer Science-XII
   411   412   413   414   415   416   417   418   419   420   421