#include<stdio.h>
#include<math.h>
double my_expTaylor(double x,unsigned n)
{
unsigned j=1,i=0;
double t=1,c=0,a,b;
while(i<=n)
{
if(i==0)
{
t=1;
a=1;
}
else
{
a=pow(x,i);
while(j<=i)
{
t=t*j;
j=j++;
}
b=a/t;
c=c+b;
i++;
}
}
return(c);
}
void main()
{
unsigned k,a[11];
double x=3.0;
for(k=0;k<11;k++)
a[k]=k;
for(k=0;k<11;k++)
{
printf("%d\n",my_expTaylor(x,a[k]));
}
}
mosci
相关分类