请高人指点一下错在了哪里?该如何处理
请高人指点一下错在了哪里?
# include<stdio.h>
# include<math.h>
double fact(int n);
int main(void)
{
int x,i;
scanf("%d",&x);
double s;
i=1;
s=0;
while(pow(x,i)/fact(i)>0.00001){
s=s+pow(x,i)/fact(i);
i++;
}
return 0;
}
double fact(int n);
{
int i;
double product;
product=1;
for(i=1;i<=n;i++){
product=product*i;
}
return product;}
/*以下是报错信息:Compiling...
Cpp3.cpp
E:\计算机\c语言\Cpp3.cpp(18) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.*/
------解决方案--------------------
double fact(int n);这里有一个分号啊,看一下编译信息和行号。。。。另外就是以后贴代码用代码格式,大家看起来都方便
------解决方案--------------------
!!上来转转
------解决方案--------------------
# include<stdio.h>
# include<math.h>
double fact(int n);
int main(void)
{
int x,i;
scanf("%d",&x);
double s;
i=1;
s=0;
while(pow(x,i)/fact(i)>0.00001){
s=s+pow(x,i)/fact(i);
i++;
}
return 0;
}
double fact(int n);
{
int i;
double product;
product=1;
for(i=1;i<=n;i++){
product=product*i;
}
return product;}
/*以下是报错信息:Compiling...
Cpp3.cpp
E:\计算机\c语言\Cpp3.cpp(18) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.*/
------解决方案--------------------
double fact(int n);这里有一个分号啊,看一下编译信息和行号。。。。另外就是以后贴代码用代码格式,大家看起来都方便
------解决方案--------------------
!!上来转转
------解决方案--------------------
- C/C++ code
#include<stdio.h> # include<math.h> double fact(int n); int main(void) { int x,i; scanf("%d",&x); double s; i=1; s=0; while(pow(x,i)/fact(i)>0.00001) { s=s+pow(x,i)/fact(i); i++; } return 0; } double fact(int n)//这里删除分号就行了 { int i; double product; product=1; for(i=1;i<=n;i++) { product=product*i; } return product; }
------解决方案--------------------
函数定义时,不应在函数头后加“;”,还有一个不建议使用的ASII C++中头文件后不建议加“.h”
------解决方案--------------------
楼上正解
------解决方案--------------------
囧。。。。。。。。。。。
------解决方案--------------------
???
------解决方案--------------------
------解决方案--------------------
double fact(int n);
多了个分号,定义时候不用加分号