int right(int n)
{
if(n>0)
{
n--;
top_lim ++;
cout<<"R";
right_lim--;
if(right_lim < size)
return(right(n-1));
if(top_lim>0)
--> return(up(n - 1));
}
else
{
return 0;
}
}
int up(int n)
{
if(n>1)
{
n--;
top_lim --;
cout<<"U";
if(right_lim < size)
return(right(n-1));
if(top_lim > 0 )
return(up(n-1));
}
else
{
return 0;
}
}
error: [17] 'up' was not declared in this scope|--> indicates error in code ..
问题描述:
问题是在从(0,0)到(n,n)的对角线下方的部分找到n * n网格中所有可能的路径数 我基本上首先在main函数中调用正确的函数,然后它应该打印所有路径。
有解决方法吗?
答案 0 :(得分:6)
在代码顶部添加转发声明:
int up(int);
(确保使用完全优化编译该代码!:-))