Link to home
Start Free TrialLog in
Avatar of rmtogether
rmtogether

asked on

function procedure design

hi,
I have a program like below:
the problem is the backtrack() will return me more than one set of (newt[N][i][j] != 0), but only first set goes to addpath(N, i, j). how can I let the program run every set of  (newt[N][i][j] != 0)?


---------------------------------------
main ()
{
backtrack();
system("pause");
return 0;
}

void backtrack(void)
{
   for (i=0; i<3;i++){  
      for (j=0; j<3; j++) {
           if (newt[N][i][j] != 0)
           {    
               addpath(N, i, j);        
            }//end if
       }// 3rd for      
      } // 2nd for  
}
----------------------------------------------------------------------------

<ps> the addpath(N, i, j) will continue call other functions.....but I am sure that the final function is looks like

void addpath (int s, int i, int j)
{
  if( s == 0 )
  {
    printf("final path is %d%d%d : \n",s,i,j);
    printf("finish!!\n");-------------------------------------------->> end here
    return;
  }
   call other functions....
}
ASKER CERTIFIED SOLUTION
Avatar of PaulCaswell
PaulCaswell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmtogether
rmtogether

ASKER

thanks PaulCaswell

I got it... by the way, can I ask you last question?

Since I might got couple sets of i , j (newt[N][i][j] != 0) to put in addpath(N, i, j), how can I design my addpath() to know each set of i, j and how many times ddpath(N, i, j) has called

<ps>
this is because my program need to know each set of i,j and also addpath()  will respond different actions every time called


----------------------------------------------------------
           if (newt[N][i][j] != 0)
           {    
               addpath(N, i, j);        
            }//end if


void addpath (int s, int i, int j)
{
  if( s == 0 )
  {
    printf("final path is %d%d%d : \n",s,i,j);
    printf("finish!!\n");
    return;
  }
   call other functions....
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

thanks, marchent

since this is different question, I guess i should closed this one and open another.

I have open another question, base on this idea...could you please take a look. thanks in advance.

https://www.experts-exchange.com/questions/22059132/procedure-design.html