请高人指点一下错在了哪里?

renjunqing 2010-04-17 11:47:55
# 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 时出错.*/
...全文
76 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingteng 2010-04-17
  • 打赏
  • 举报
回复
double fact(int n);这里有一个分号啊,看一下编译信息和行号。。。。另外就是以后贴代码用代码格式,大家看起来都方便
cattycat 2010-04-17
  • 打赏
  • 举报
回复
double fact(int n);
多了个分号,定义时候不用加分号
喜-喜 2010-04-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 junzhione 的回复:]
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……
[/Quote]

up....
xiaoqiang0409 2010-04-17
  • 打赏
  • 举报
回复
???
macrojj 2010-04-17
  • 打赏
  • 举报
回复
囧。。。。。。。。。。。
jmppok 2010-04-17
  • 打赏
  • 举报
回复
楼上正解
wxwlll 2010-04-17
  • 打赏
  • 举报
回复
函数定义时,不应在函数头后加“;”,还有一个不建议使用的ASII C++中头文件后不建议加“.h”
junzhione 2010-04-17
  • 打赏
  • 举报
回复

#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;
}
dduwyyanother 2010-04-17
  • 打赏
  • 举报
回复
!!上来转转

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧