【发布时间】:2016-03-14 03:42:25
【问题描述】:
我收到了这个错误:
错误 1 错误 C2064:术语不计算为采用 1 个参数的函数
上线:
discr=((pow(b, 2))-4(a*c));
二次公式程序代码:
#include "stdafx.h"
#include <iostream>
#include "math.h"
using namespace std;
float a, b, c, d,x1, x2, discr;
int ec2g(float a, float b, float c, float & x1, float & x2);
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"'a'"<<endl;
cin>>a;
cout<<"'b'"<<endl;
cin>>b;
cout<<"'c'"<<endl;
cin>>c;
if (ec2g(a, b, c, x1, x2)){
cout<<x1<<x2<<endl;
}
else{
cout<<"No solution"<<endl;
}
return 0;
}
int ec2g(float a, float b, float c, float & x1, float & x2){
int solreal=0;
discr=((pow(b, 2))-4(a*c));
if(discr>0.0){
solreal=1;
x1=(-b+sqrt(discr)/(2.0*a));
x2=(-b-sqrt(discr)/(2.0*a));
}
return solreal;
}
知道如何解决这个问题吗?
【问题讨论】:
-
首先去掉所有括号,除了调用
pow的括号;他们不需要。在这些干扰消失后,问题应该很明显了。 -
你的全局变量应该都是局部变量
标签: c++ arguments term evaluate reference-parameters