C
cplusplusquestion
As discussion last time, I am thinking if it is possible to change the
recursive function from:
void fun(Array a){
for (int i=0; i<MAX1; i++)
for(int j=0; j<MAX2; j++){
if ( a[j] != -1) {
/*... using a[j] to calculate some value...*/
a[j]=-1;
fun(a);
}
}
to:
void fun(Array& a){
/*......*/
}
and make sure the result will be same.
recursive function from:
void fun(Array a){
for (int i=0; i<MAX1; i++)
for(int j=0; j<MAX2; j++){
if ( a[j] != -1) {
/*... using a[j] to calculate some value...*/
a[j]=-1;
fun(a);
}
}
to:
void fun(Array& a){
/*......*/
}
and make sure the result will be same.