- 问答
T1058 求解一元二次方程
- 2023-11-29 17:49:38 @
这道题怎么写啊。。 谁能告诉我根号用程序怎么写啊 ? :)
3 comments
-
经开一中2026届11班关泽瑞 LV 6 @ 2023-11-29 20:39:11
算术平方根sqrt()
-
2023-11-29 20:38:16@
#include <bits/stdc++.h> using namespace std; int main() { double a , b , c , x1 , x2 , d; cin >> a >> b >> c; d = b * b - 4 * a * c; if ( d < 0 ) { cout << "No answer!" << endl; return 0; } x1 = ( -b + sqrt( d ) ) / ( 2 * a ); x2 = ( -b - sqrt( d ) ) / ( 2 * a ); if ( d == 0 ) printf( "x1=x2=%.5lf\n" , x1 ); if ( d > 0 ) { if ( x1 < x2 ) printf( "x1=%.5lf;x2=%.5lf\n" , x1 , x2 ); else printf( "x1=%.5lf;x2=%.5lf\n" , x2 , x1 ); } return 0; }
-
2023-11-29 18:31:35@
sqrt()
- 1