C语言编程高手来帮忙编个程序啊!马上就要!

来源:百度知道 编辑:UC知道 时间:2024/05/06 17:02:14
用循环帮忙做下面式子的答案啊!要详细的程序哦~谢谢啊!
求: 1!+3!+5!+7!+9!+11!
也就是1+1*2*3+1*2*3*4*5+1*2*3*4*5*6*7+1*2*3*4*5*6*7*8*9+1*1*2*3*4*5*6*7*8*9*10*11
谢谢哦~~~~要快啊!
哇哇~~~要最基础的做法啊!我刚学!看不懂啊!我就只学到了循环!只明白for和while语句啊!

已经添加不用函数的了.......
PS:飘渺世间天 程序精彩,高手!

#include <stdio.h>

/*计算方法1使用的函数*/
unsigned int jc(unsigned int n)
{
static unsigned int rt = 1;
return rt *= n;
}

/*计算方法2使用的函数*/
int jc1(int n)
{
return n <= 1 ? 1 : n * jc1(n-1);
}

int main()
{
unsigned int i = 1;
unsigned int result = 0;
unsigned int t;
unsigned int flag = 1;

/*计算方法1*/
while (i <= 11)
result += flag * jc(i++), flag = (flag + 1) % 2;
printf("the result is:%d\n", result);

/*计算方法2*/
result = 0;
for (i = 1; i < 12; i += 2)
result += jc1(i);
printf("the result is:%d\n", result);

/*计算方法3*/
t = 2;
result = 1;
i = 3;
while (i <= 11)
{
t *= i++;
result += t;
t *= i++;
}
printf("the result is:%d\n", result);/*你看得懂的算