11 solutions

  • 4
    @ 2023-9-17 11:36:40
    #include<bits/stdc++.h>
    using namespace std;
    double a,b,c,d,e,deerta;
    int main(){
    	scanf("%lf %lf %lf",&a,&b,&c);
    	deerta=pow(b,2)-4*a*c;
    	if(deerta>0){
    		d=(-b-sqrt(deerta))/2/a;
    		e=(-b+sqrt(deerta))/2/a;
    		printf("x1=%.5f;x2=%.5f",d,e);
    	}
    	else if(deerta==0){
    		d=(-b-sqrt(deerta))/2/a;
    		printf("x1=x2=%.5f",d);
    	}
    	else cout<<"No answer!";
    	return 5201314;
        //有防抄袭代码,注意避坑
    }
    
    • 2
      @ 2023-9-20 22:34:37
      #include<iostream>
      #include<iomanip>
      #include<cmath>
      using namespace std;
      long double a,b,c,x1=0,x2=0,s;
      int main(){
      	cin>>a>>b>>c;
      	s=b*b-4*a*c;
      	if(s>0){
      		x1=(-b-sqrt(s))/(2*a);
      		x2=(-b+sqrt(s))/(2*a);
      		cout<<"x1="<<fixed<<setprecision(5) <<x1<<";"<<"x2="<<fixed<<setprecision(5)<<x2;
      	}else if(s==0){
      		x1=(-b+sqrt(s))/(2*a);
      		cout<<"x1=x2="<<x1;
      	}else if(s<0) cout<<"No answer!";
      	return 0;
      }
      
    • 2
      @ 2023-9-16 16:31:19

      #include<bits/stdc++.h> using namespace std; int main(){ double a=0,b=0,c=0,d=0,e=0,deerta=0; scanf("%lf %lf %lf",&a,&b,&c); deerta=pow(b,2)-4ac; if(deerta>0){ d=(-b-sqrt(deerta))/2/a; e=(-b+sqrt(deerta))/2/a; printf("x1=%.5f;x2=%.5f",d,e); } else if(deerta=0){ d=(-b-sqrt(deerta))/2/a; printf("x1=x2=%.5f",d); } else{ printf("No answer!"); } return 0; }

      • 0
        @ 2024-10-30 17:54:03

        包对的

        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        	double a,b,c;
        	cin>>a>>b>>c;
        	double d=pow(b,2)-4.0*a*c;
        	if(d<0){
        		cout<<"No answer!";
        	}else if(d==0){
        		double e=(-b)/(2.0*a);
        		printf("x1=x2=%.5f",e);
        	}else{
        		double e=(-b+sqrt(d))/(2.0*a),f=(-b-sqrt(d))/(2.0*a);
            if(e>f){
              swap(e,f);
            }
        		printf("x1=%.5f;x2=%.5f",e,f);
        	}
        	return 0;
        }
        • 0
          @ 2023-10-6 11:35:33
          #include <bits/stdc++.h>
          using namespace std;
          int main(int argc, char **argv){
          	double a,b,c,x1,x2,x;	// 一定要用 double
          	cin >> a >> b >> c;
          	x = b * b - 4 * a * c;
          	if (x > 0){
          		x1 = (-b + sqrt(b * b - (4 * a * c))) / (2.0 * a);
          		x2 = (-b - sqrt(b * b - (4 * a * c))) / (2.0 * a);
          		printf("x1=%.5f;x2=%.5f",min(x1,x2),max(x1,x2));
          	}else{
          		if (x == 0){
          			x1 = (-b - sqrt(x)) / (2.0 * a);
          			printf("x1=x2=%.5f",x1);
          			return 0;
          		}
          		printf("No answer!");
          	}
          	return 0;
          }
          
          • 0
            @ 2023-9-16 23:23:55

            100%过

            #include<bits/stdc++.h> using namespace std; int main(){ double a=0,b=0,c=0,d=0,e=0,deerta=0; scanf("%lf %lf %lf",&a,&b,&c); deerta=pow(b,2)-4ac; if(deerta>0){ d=(-b-sqrt(deerta))/2/a; e=(-b+sqrt(deerta))/2/a; printf("x1=%.5f;x2=%.5f",d,e); } else if(deerta==0){ d=(-b-sqrt(deerta))/2/a; printf("x1=x2=%.5f",d); } else{ printf("No answer!"); } return 0; }


            点个赞吧:))))))))))))))))))))))))))))

            • 0
              @ 2023-9-16 23:22:30

              100%过

              
              

              #include<bits/stdc++.h> using namespace std; int main(){ double a=0,b=0,c=0,d=0,e=0,deerta=0; scanf("%lf %lf %lf",&a,&b,&c); deerta=pow(b,2)-4ac; if(deerta>0){ d=(-b-sqrt(deerta))/2/a; e=(-b+sqrt(deerta))/2/a; printf("x1=%.5f;x2=%.5f",d,e); } else if(deerta==0){ d=(-b-sqrt(deerta))/2/a; printf("x1=x2=%.5f",d); } else{ printf("No answer!"); } return 0; }

              
              
              • -1
                @ 2024-1-21 9:29:55

                #include using namespace std; int main() { long double a, b, c; cin >> a >> b >> c; long double deilta = b * b - 4.0 * a * c; if(deilta < 0) { cout << "No answer!" << endl; return 0; } else { if(delta == 0) { long double x = ( - b + sqrt(delta)) / (2 * a); cout << "x1=x2=" << fixed << setprecision(5) << x << endl; return 0; } else { long double x1, x2; x1 = ( - b + sqrt(delta)) / (2.0 * a); x2 = ( - b - sqrt(delta)) / (2.0 * a); cout << "x1=" << fixed << setprecision(5) << min(x1,x2) << ";x2=" << fixed << setprecision(5) << max(x1,x2) << endl; return 0; } } return 0; } //有防伪代码 //建议别抄我的,我的代码变量有些zz //(^_^)

                • -1
                  @ 2023-9-16 16:30:15

                  #include<bits/stdc++.h> using namespace std; int main(){ double a,b,c; cin>>a>>b>>c; double x1,x2; if(bb-4ac<0) cout<<"No answer!"; else if(bb-4ac==0) cout<<"x1=x2="<<fixed<<setprecision(5)<<-b/2a; else{ x1=(-b+sqrt(bb-4ac))/(2a); x2=(-b-sqrt(bb-4ac))/(2*a); if(x1<x2) cout<<"x1="<<fixed<<setprecision(5)<<x1<<";x2="<<fixed<<setprecision(5)<<x2; else cout<<"x1="<<fixed<<setprecision(5)<<x2<<";x2="<<fixed<<setprecision(5)<<x1; }; return 0; }

                  • -2
                    @ 2024-7-9 20:13:17

                    #include<bits/stdc++.h> using namespace std;

                    int main(){ double a,b,c,x1,x2; cin>>a>>b>>c; double d =(bb-4a*c);

                    if(d<0){
                    	 cout<<"No answer!";
                    	 return 0;
                    }
                    x1=(-b+sqrt(d))/2/a;
                    x2=(-b-sqrt(d))/2/a;
                    
                    if(d==0){
                    	cout<<fixed<<setprecision(5)<<"x1=x2="<<x1;
                    }else {
                    	cout<<fixed<<setprecision(5)<<"x1="<<min(x1,x2)<<";x2="<<max(x1,x2);
                    }
                    

                    }

                    • -2
                      @ 2023-10-5 21:01:06

                      #include

                      #include

                      #include

                      using namespace std;

                      long double a,b,c,x1=0,x2=0,s;

                      int main(){

                      cin>>a>>b>>c;

                      s=bb-4a*c;

                      if(s>0){

                      x1=(-b-sqrt(s))/(2*a);

                      x2=(-b+sqrt(s))/(2*a);

                      cout<<"x1="<<fixed<<setprecision(5) <<x1<<";"<<"x2="<<fixed<<setprecision(5)<<x2;

                      }else if(s==0){

                      x1=(-b+sqrt(s))/(2*a);

                      cout<<"x1=x2="<<x1;

                      }else if(s<0){

                      cout<<"No answer!";

                      }

                      return 0;

                      }

                      • 1

                      Information

                      ID
                      546
                      Time
                      1000ms
                      Memory
                      256MiB
                      Difficulty
                      7
                      Tags
                      # Submissions
                      326
                      Accepted
                      83
                      Uploaded By