解题思路:
注意事项:
注意输出数据的大小,有可能会超过int 的限制
参考代码:
#include <stdio.h>
//using namespace std;
//#define LINT64 (long)
long proc(int a);
long Process(int a);
int main()
{
int a;
long b;
scanf("%d",&a);
b = Process(a);
printf("%lld\n",b);
return 1;
}
long Process(int a)
{
int i;
long sum = 0;
if((a<0) || (a>20))
{
return 0;
}
if(a==1)
{
return 1;
}
for(i=1; i<=a;i++)
{
sum += proc(i);
}
return sum;
}
long proc(int a)
{
if(a==1)
{
return 1;
}
else
{
return a*(proc(a-1));
}
}
0.0分
1 人评分