Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a,b,c;
- float delta;
- cout<<"nhap vao a,b,c"<<endl;
- cin >> a;
- cin >> b;
- cin >> c;
- delta=b*b-4*a*c;
- if (a==0)
- {
- if (b!=0)
- { cout << "nghiem cua phuong trinh: "<< -float(c)/float(b);
- }
- else
- {
- if(c!=0)
- {
- cout<<"phuong trinh vo nghiem";
- }
- else
- {
- cout<<"phuong trinh vo so nghiem";
- }
- }
- }
- else
- {
- if(delta<0)
- {
- cout<<"phuong trinh vo nghiem";
- }
- else
- {
- if(delta==0)
- {
- cout<<"phuong trinh co 1 nghiem kep x1 = x2 = "<< -float(b)/(2*float(a));
- }
- else
- {
- cout<<"nghiem x1 = "<< (-float(b)+ sqrt(delta))/(2*float(a))<<endl;
- cout<<"nghiem x2 = "<< (-float(b)- sqrt(delta))/(2*float(a));
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement