#include<stdio.h>
int main(void)
{
int n,i,flag;
double x,sum,item;
double power(x,n);
double fact(int n);
sum=0;flag=1;item=0;
printf("请输入一个正整数:");
scanf("%d",&n);
printf("请输入一个实数:");
scanf("%lf",&x);
if(x>=0)
{
for(i=1;i<=n;i++)
{item=power(x,n)/fact(i);
sum=sum+flag*item;}
printf("x=%lf,n=%d,s=%lf",&x,&n,&sum);
}
else
{ for(i=1;i<=n;i++)
{item=fact(i)/power(x,n);
sum=sum+flag*item;}
printf("x=%lf,n=%d,s=%lf",&x,&n,&sum);
}
double fact(n)
{ int i; double product;
product=1 ;
for(i=1;i<=n;i++)
{product=product*i;}
return product;
}
double power(x,n)
{
int i,n;
double x,pow;
pow=1.0;
for(i=1;i<=n;i++)
pow=pow*x;
return pow;
}
}这是文件里的程序
编译后出现C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(6) : error C2078: too many initializers
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : error C2018: unknown character '0xa3'
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : error C2018: unknown character '0xa8'
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : error C2143: syntax error : missing ';' before 'string'
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : warning C4551: function call missing argument list
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : error C2018: unknown character '0xa3'
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(13) : error C2018: unknown character '0xa9'
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(17) : error C2064: term does not evaluate to a function
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(23) : error C2064: term does not evaluate to a function
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(28) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(29) : error C2065: 'product' : undeclared identifier
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(35) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(38) : error C2065: 'pow' : undeclared identifier
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(38) : warning C4244: '=' : conversion from 'const double' to 'int', possible loss of data
C:\Users\lenovo\Desktop\实验素材\自主实验\实验02 C语言简单程序设计\第9题\Cpp1.cpp(40) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
大神们出来帮帮忙吧