正在加载图片...
#include<bits/stdc++.h>/C++的万能头文件 using namespace std; int main() double a,b,c; double x1,x2,del,shi,xu; cin >>a>>b>>ci del =b*b-4*a*c; if(del ==0) { x1=x2=-b/八2*ai cout <<fixed <setprecision(5)<<"x1=x2="<<x1<<endl; } if(del>0) x1=(-b+sqrt(del)/八2*a); x2=(-b-sqrt(del))/(2*a); cout <<fixed <setprecision(5)<<"x1="<<x1 <<",x2="<<x2 <<endl; if(del <o) shi=-b/(2*a); xu=sqrt((4*a*c-b*b))/(2*a); cout <<fixed <setprecision(5)<<"x1="<<shi<<"+"<<xu<<"i"<<""; cout <<fixed <setprecision(5)<<"x2="<<shi<<""<<xu<<"i"<<endl; } return 0;#include <bits/stdc++.h> //C++的万能头文件 using namespace std; int main() { double a,b,c; double x1,x2,del,shi,xu; cin >>a >> b >> c; del = b*b-4*a*c; if( del == 0) { x1 = x2 = -b/(2*a); cout <<fixed << setprecision(5)<< "x1=x2="<<x1 <<endl; } if(del > 0) { x1 = (-b+sqrt(del))/(2*a); x2 = (-b-sqrt(del))/(2*a); cout <<fixed << setprecision(5)<<"x1="<<x1 <<",x2="<<x2 <<endl; } if( del < 0) { shi = -b/(2*a); xu = sqrt((4*a*c-b*b))/(2*a); cout <<fixed << setprecision(5)<< "x1="<<shi<<"+"<<xu<<"i"<<","; cout <<fixed << setprecision(5)<< "x2="<<shi<<"-"<<xu<<"i"<<endl; } return 0; }
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有