c++
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int a,b,c; int main() { cin>>a>>b>>c; cout<<setiosflags(ios::fixed)<<setprecision(4); if((b*b-4*a*c)>0) { double x=(-b-sqrt(double(b*b-4*a*c)))/2/a; double y=(-b+sqrt(double(b*b-4*a*c)))/2/a; if(x<y) cout<<x<<endl<<y; else cout<<y<<endl<<x; } if((b*b-4*a*c)==0) cout<<(-b+sqrt(1.0*(b*b-4*a*c)))/(2*a)<<endl; if((b*b-4*a*c)<0) cout<<"No Answer!"<<endl; return 0; }
#include<iostream>//p1018 #include<cmath> #include<iomanip> using namespace std; int main() { int a,b,c; int flag1=0,flag2=0,flag3=0; cin>>a>>b>>c; if(a+b>c&&a+c>b&&b+c>a) { if(a==b&&b==c) cout<<"yse"<<endl; else cout<<"no"<<endl;; if(a==b||a==c||b==c) cout<<"yse"<<endl; else cout<<"no"<<endl; cout<<"yse"<<endl; } else cout<<"no"<<endl<<"no"<<endl<<"no";//第一种写法 //第二种 if(a==b&&b==c) flag1=1; if(a==b||b==c||a==c) flag2=1; if(a+b>c&&a+c>b&&b+c>a) flag3=1; if(flag3==0) { cout<<"no"<<endl<<"no"<<endl<<"no"; return 0; } if(flag1) cout<<"yse"<<endl; else cout<<"no"<<endl; if(flag2) cout<<"yse"<<endl; else cout<<"no"<<endl; cout<<"yse"; return 0; }
我就是有点儿无聊⊙﹏⊙