在同一个程序中从函数y中调用函数x,反之亦然
Calling function x from within function y and vice versa in the same program
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 ..
问题描述:
问题是找出n*n网格中从(0,0)到(n,n)的对角线以下部分的所有可能路径数我基本上首先在main函数中调用正确的函数,然后它应该打印出所有的路径。
是否有解决这个问题的方法?
在代码顶部添加一个向前声明:
int up(int);
(确保用完全优化编译代码!): -)
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- C :使用函数过载与CHAR到INT之间的隐式转换,反之亦然
- 调用成员函数(如果存在),回退到自由函数,反之亦然
- 将非按引用变量分配给返回按引用的函数,反之亦然
- 在C++中访问 Lua 函数的返回值,反之亦然
- c++ 将函数输出重定向到编译的程序输入,反之亦然
- 在另一个类的函数中返回一个类,反之亦然,编译错误(递归)
- C++-独立于平台的函数,用于将字节数组转换为值,反之亦然
- 我可以使用什么winapi C函数调用来将unicode转换为ascii,反之亦然
- 在c++中,什么时候使用虚函数而不是重写函数最有利,反之亦然
- 函数A调用函数B,反之亦然(为什么不起作用)
- 在同一个程序中从函数y中调用函数x,反之亦然
- 将{带有C链接的函数指针}赋值给{带有c++链接的函数指针},反之亦然