下面是我写的一段代码输入1 2 3 之后结果根为2 为什么不是为1??求帮助
#include <iostream>#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
double f(double y, double a, double b);
double a, b, y, x;
cout<<"请输入a,b和y的值:"<<endl;
cin>>a>>b>>y;
x = (y, a, b);
cout<<"方程的根为:"<<x<<endl;
return EXIT_SUCCESS;
}
double f(double y, double a, double b)
{
double x;
x = (y - b) / a;
cout<<y<<" "<<a<<" "<<b<<endl;
return x;
}