这道题怎么写啊。。 谁能告诉我根号用程序怎么写啊 ? :)

3 comments

  • 算术平方根sqrt()

    • #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