1 条题解

  • 0
    @ 2024-12-18 14:07:29

    C :

    #include<stdio.h>
    #include<math.h>
    
    int main()
    {
        double a,b,c,R1,R2;
    	scanf("%lf %lf %lf", &a, &b, &c);
    	if ((b*b-4*a*c) < 0 || a==0)
    	{
    	    printf("Impossivel calcular");
    	}
    	else
    	{
    		R1=(-b+sqrt(b*b-4*a*c))/(2*a);
    		R2=(-b-sqrt(b*b-4*a*c))/(2*a);
    	    printf("R1 = %.5lf\n",R1);
    		printf("R2 = %.5lf\n",R2);
    	}
    
    
        return 0;
    }
    

    C++ :

    #include<bits/stdc++.h>
    
    
    using namespace std;
    
    int main()
    {
        double a,b,c;
      
        scanf("%lf %lf %lf",&a,&b,&c);
        
    
        if(a==0||b*b-4*a*c<0) 
        printf("Impossivel calcular");
    
        else if(b*b-4*a*c>0)
        printf("R1 = %.5lf\nR2 = %.5lf\n",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a));
    
        
    
        return 0;
    }
    
    
    
    • 1

    信息

    ID
    644
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    提交数
    196
    已通过
    38
    上传者