quocdat11 |
Date: Sunday, 02/11/2008, 2:32 PM | Message # 1 |
Nhóm: Removed
|
#include #include #include int ptb1(float a,float b) { float x; if(a == 0){ if(b == 0) cout<<"phuong trinh vo so nghiem: "; else cout<<"phuong trinh vo nghiem: "; } else{x=-b/a; cout<<"phuong trinh co nghiem:x= "<< x; } return 0; } int ptb2(float a,float b,float c) { float d,x1,x2; if(a == 0) ptb1(b,c); else { (d=(b*b)-(4*a*c)); if (d <0) { cout<<"phuong trinh vo nghiem: ";} else if(d == 0) { x1=-b/(2*a); cout<<"phuong trinh co nghiem kep: "<< x1;} else{ x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); cout<<"phuong trinh co 2 nghiem: "<< endl; cout<<"x1= "< cout<<"x2= "< return 0; } } } int main() { float a,b,c; clrscr(); cout<<"nhap he so a= "; cin>>a; cout <<"nhap he so b= "; cin>>b; cout<<"nhap he so c= "; cin>>c; ptb2(a,b,c); getch(); return 0; } |
|
| |