Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main(){
- int a;
- int b;
- int c;
- int delta = (pow(b,2)- 4*a*c) ;
- cout<<"phuong trinh ax^2+bx+c=0 , nhap vao a,b,c de bat dau giai"<< endl;
- cout<<"a : "; cin>> a;
- cout<<"b : "; cin>> b;
- cout<<"c : "; cin>> c;
- if (a==0)
- {
- cout<<"pt co nghiem la : "<< -b/c ;
- }
- else
- {
- if (delta < 0)
- {
- cout<<"pt vo nghiem ! ";
- }
- else
- {
- if (delta = 0)
- {
- cout<<"phuong trinh co nghiem kep la : "<<-b/(2*a);
- }
- else
- {
- cout<<"pt co 2 nghiem phan biet la "<< (-b - sqrt(delta))/(2*a)<< " va "<<(-b + sqrt(delta))/(2*a);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement