Bài 7. Nhập a, b nguyên. Hãy giải và biện luận phương trình ax + b = 0.
- Nếu vô nghiệm thông báo None.
- Nếu vô số nghiệm thông báo Multiple.
- Nếu có nghiệm, đưa ra dạng x = -b / a;
Ví dụ:
PTBN.INP |
PTBN.OUT |
0 6 |
None |
Code tham khảo:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
freopen("PTBN.INP","r",stdin);
freopen("PTBN.OUT","w",stdout);
int a, b;
cin >> a >> b;
if (a == 0)
if (b == 0) cout << "Multiple";
else cout << "None";
else cout << (float)-b / a;
return 0;
}