文章
145
粉丝
217
获赞
21
访问
85.4k
#include <stdio.h>
double Factorial(int n)
{
int i;
double fact = 1.0;
for(i = 1; i <= n; i++)
fact = fact*(double)i;
return fact;
}
int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
int i;
double y1 = 0.0,y2 = 0.0;
for(i = 1; i <= n; i++)
if(i % 2 == 1)
y1 += Factorial(i);
else y2 += Factorial(i);
printf("%.0lf %.0lf\n",y1,y2);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发