
C++执行下面这段代码时总提示pow函数不接受两个参数。小白等高手求解。
#include"stdafx.h"#include"iostream"usingnamespacestd;intpow(inta,intb);int_tmain(int...
#include "stdafx.h"
#include "iostream"
using namespace std;
int pow(int a, int b);
int _tmain(int argc, _TCHAR* argv[])
{
int x,n,i,lc;
float s=0;
cin>>x>>n;
int pow();
for(i=1;i<=n;i++)
{
lc=pow(x,i);
s=s+float(lc)/i;
}
cout<<'\n'<<s+1;
return 0;
}
int pow(int a,int b)
{
int x=1,y;
for(y=1;y<=b;y++)
x=x*a;
return x;
} 展开
#include "iostream"
using namespace std;
int pow(int a, int b);
int _tmain(int argc, _TCHAR* argv[])
{
int x,n,i,lc;
float s=0;
cin>>x>>n;
int pow();
for(i=1;i<=n;i++)
{
lc=pow(x,i);
s=s+float(lc)/i;
}
cout<<'\n'<<s+1;
return 0;
}
int pow(int a,int b)
{
int x=1,y;
for(y=1;y<=b;y++)
x=x*a;
return x;
} 展开
3个回答
展开全部
cin>>x>>n;
int pow(); // 这声明错了。应该有两个参数的。
int pow(); // 这声明错了。应该有两个参数的。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
pow的原型声明 和 实现 的参数有不同。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1楼正解,可声明成:int pow(int, int);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询