1 条题解

  • 1
    @ 2025-10-6 18:36:44
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    int main()
    {
    	double a,b,c,x1,x2;
    	cin >> a >> b >> c;
    	if(a == 0 || b*b - 4*a*c < 0)
    		cout << "No answer!";
    	else
    	{
    		x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
    		x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
    		/* 
    		if(x1 > x2)
    			swap(x1,x2);
    		*/
    		printf("The first root is: %.2f\nThe second root is: %.2f",x1,x2);
    	}
    	
    	return 0;
    }
    
    
    • 1

    信息

    ID
    1493
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    103
    已通过
    27
    上传者