5 條題解
-
0
#include<bits/stdc++.h> using namespace std; int main() { double a,b,c,x1/*根1*/,x2/*根2*/,n; cin>>a>>b>>c; n = b*b-4*a*c; if (n>=0)//有解 { x1 = (-b+sqrt(n))/(2*a);//根1 x2 = (-b-sqrt(n))/(2*a);//根2 if (n==0) cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;//根相等 else if (x1<x2) cout<<fixed<<setprecision(5)<<"x1="<<x1<<";x2="<<x2; else cout<<fixed<<setprecision(5)<<"x1="<<x2<<";x2="<<x1; } else cout<<"No answer!";//无解 return 0; }
資訊
- ID
- 865
- 時間
- 1000ms
- 記憶體
- 256MiB
- 難度
- 3
- 標籤
- (無)
- 遞交數
- 148
- 已透過
- 41
- 上傳者