功能模板的语法
template <**class** T, ...>
returntype functionname(arguments)
{
.....
.....
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题?
使用while循环在c中使用递归的因子程序.在该程序中,一旦执行到达函数return语句,它就不会返回到函数调用.相反,它重复执行该功能.任何人都可以告诉我这个程序有什么问题.
#include<stdio.h>
int fact(int n)
{
int x=1;
while(n>1)
{
x=n*fact(n-1);
}
return(x);
}
void main()
{
int n,fact1;
scanf("%d",&n);
fact1=fact(n);
printf("%d",fact1);
}
Run Code Online (Sandbox Code Playgroud)