2 条题解

  • 0

    #include<bits/stdc++.h>

    using namespace std;

    int main()

    {

    double a,b,c; cin>>a>>b>>c; double m=bb-4ac; if(fabs(m)<0.00001) cout<<"x1=x2="<<fixed<<setprecision(5)<<-b/(2a); else if(m>0) { double x_small=(-b-sqrt(m))/(2a); double x_big=(-b+sqrt(m))/(2a); if(x_small>x_big) { double temp=x_small; x_small=x_big; x_big=temp; } cout<<fixed<<setprecision(5)<<"x1="<<x_small<<";x2="<<x_big; } else cout<<"No answer!"; return 0; }

    • 0
      @ 2025-3-6 20:38:18

      #include<bits/stdc++.h>

      using namespace std;

      int main()

      {

      double a,b,c;
      cin>>a>>b>>c;
      double m=b*b-4*a*c;
      if(fabs(m)<0.00001)
      	cout<<"x1=x2="<<fixed<<setprecision(5)<<-b/(2*a);
      else if(m>0)
      {
      	double x_small=(-b-sqrt(m))/(2*a);
      	double x_big=(-b+sqrt(m))/(2*a);
      	if(x_small>x_big)
      	{
      		double temp=x_small;
      		x_small=x_big;
      		x_big=temp;
      	}		
      	cout<<fixed<<setprecision(5)<<"x1="<<x_small<<";x2="<<x_big;
      }
      else
      	cout<<"No answer!";
      return 0;
      

      }

      • 1

      信息

      ID
      62
      时间
      1000ms
      内存
      256MiB
      难度
      5
      标签
      递交数
      93
      已通过
      35
      上传者