1 solutions

  • 0
    @ 2025-11-5 16:19:27

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int a,b,c;
    	float r1,r2,delt;
    	scanf("%d%d%d",&a,&b,&c);
    	if(a!=0)
    	{
    	delt=b*b-4*a*c;
    	if(delt>=0)
    	{
    	r1=(-b+sqrt(delt))/(2*a);
    	r2=(-b-sqrt(delt))/(2*a);
    	if(r1==r2) printf("%.4f\n",r1);
    	if(r1!=r2) printf("%.4f %.4f\n",r2,r1);
    	}
    	if(delt<0) printf("no answer\n");
        }
    	return 0;
    }
    

    C++ :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int a,b,c;
    	float m,n,t;
    	scanf("%d %d %d",&a,&b,&c);
    	t=b*b-4*a*c;
    	if(t>0)
    	{
    		m=(-b+sqrt(t))/(2*a);
    		n=(-b-sqrt(t))/(2*a);
    		printf("%.4f %.4f",n,m);
    	}
    	if(t=0)
    	{
    		m=(-b+sqrt(t))/(2*a);
    		printf("%.4f\n",m);	
    	}
    	if(t<0)
    	{
    		printf("no answer");
    	}
    	return 0;	
    }
    
    • 1

    Information

    ID
    17682
    Time
    1000ms
    Memory
    12MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By