注册 登录
编程论坛 C++教室

下面是我写的一段代码输入1 2 3 之后结果根为2 为什么不是为1??求帮助

w716169470 发布于 2013-09-24 15:33, 432 次点击
#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;
}
2 回复
#2
sunny孙2013-09-24 15:38
x = (y, a, b);??逗号运算?不是函数调用啊···
#3
w7161694702013-09-24 15:40
回复 2楼 sunny孙
十分感谢
1