/*
@desc:用C语言编写程序 s=2!/1!+4!/(1!-3!)+6!/(1!-3!+5!)+8!/(1!-3!+5!-7!)+10!/(1!-3!+5!-7!+9!)
@author:Sigma
@date:2014.06.01
*/
#include"stdafx.h";
#include
/*阶乘*/
int getFactorial(int num){
if (num > 1 ){
return num * getFactorial(num - 1);
}
团皮else{
return 1;
}
}
void main(){
//printf("%d", getFactorial(5) );//test
float sum = 0;
int divisor = 0;//除数
for (int i = 2; i <= 10; i+=2 ){
if (i%4!=0){
拆或敬 旅慎divisor += getFactorial(i-1);
}
else{
divisor -= getFactorial(i - 1);
}
int fi = getFactorial(i);
sum += (float)fi / divisor;
}
printf("Result:%f\n", sum);
getchar();
}
#include
int calc(int n)
{
if (0 == n || 1 == n)
{
return 1;
}
return n * calc(n -1);
}
void main()
{
int s = 0;
int fenmu 并高= 0;
for (int i = 1; i <= 5; i++)
{
if (i%2 == 0)
{
fenmu -= calc(2*i-1);
}
else
{
fenmu += calc(2*i-1);
锋蔽仿 }
银纤
s += calc(2*i)/fenmu;
}
printf("s = %d", s);
}
欢迎采纳!
//尺首#include "stdafx.h"//vc++6.0加上这一行.
#include "stdio.h"
int myfact(int n){
if(n==1) return 1;
else return n*myfact(n-1);
}
void main(void){
int i,f;
double sum,k;
for(f=-1,sum=k=0,i=1;i<10;i+=2)
sum+=myfact(i+1)/型大(k+=(f=-f)*myfact(i));
printf("The result is %g\n"卜困竖,sum);
}