Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 C 编程,我试图通过使用这个原型来编写一个递归函数:
void fact(int *n);
此函数的参数应通过引用传递。谢谢你的帮助。
我觉得对提供完整的解决方案没有帮助——这只是为了表明有一个答案:
void fact(int *n) { if (*n > 1) { int tmp = *n - 1; fact(&tmp); *n *= tmp; } }
我永远不会以这种方式编写阶乘函数。