[C++] Giải phương trình bậc nhất ax + b

[C++] Giải phương trình bậc nhất ax + b




Lời giải (Code C++)
__________________________________________

#include <iostream>

#include <math.h>

using namespace std;
int main()
{
    double a,b;
    cout<<"Nhap a: ";cin>>a;
    cout<<"Nhap b: ";cin>>b;
    if (a==0)
        if (b!=0) cout<<"Phuong trinh vo nghiem";
        else cout<<"Phuong trinh co vo so nghiem";
    else
        cout<<"Phuong trinh co nghiem x= "<<-b/a;
    return 0;
}

Comments

Post a Comment

Popular Posts