求ax+b=c中x 要求a b c从键盘输入 输出x 用c++编写

来源:百度知道 编辑:UC知道 时间:2024/05/15 09:05:45
谢谢

#include<iostream>
using namespace std;
int main()
{
float a=?,b=?,c=?,x;
cout<<"please enter the no x:"
cin>>x;
cout<<endl;
x=(c-b)/a;
cout<<x<<endl;
}

double a,b,c,x;
cin>>a>>b>>c;
cout<<(c-b)/a<<endl;

#include<iostream>
using namespace std;
int main()
{
double a,b,c,x;
cout<<"输入a,b,c:"<<endl;
cin>>a>>b>>c;
if(a==0 && b==c)
cout<<"此方程有无穷解!"<<endl;
else if(a!=0)
cout<<"x="<<(c-b)/a<<endl;
else
cout<<"此方程无解!"<<endl;
return 0;
}