Write the program to determine the maximum possible way to reach the end from starting in game board.

 

      

#include<iostream>
#include<string>
using namespace std;


  int maxpath(int str, int end)
   {   if(str==end)
           {  return 1;}
//when number of blocks be lessthen no of jumps(max jump 6)
     if (str>end)  

    {return 0;}// then this condition will follow satisfy. 

          
       
        int count=0;
         for(int i=1;i<=6;i++)
        {  count =count + maxpath(str+i,end);}
      return count;  
     }   

           

int main()
{    int  str=1;//str = start
      int end=3; 
   cout<<maxpath(str,end);

    return 0;
}

  • Click on the below link and run  this program

Comments

Popular posts from this blog

Use of Recursion