0

このエラーが発生しました:

エラー 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;
}

どうすればこれを修正できますか?

4

1 に答える 1

1

乗算するのを忘れました。そのため、コンパイラはそれが関数呼び出しのように見えると考えました。

4*(a*c)
 ^

ちなみに、どちらも必要ありませんpow。ただ行う:

discr = b * b - 4.0f * a * c;
于 2016-03-14T03:45:14.047 に答える