一道c语言编程题,下图第三题,急求高手解答,要代码,谢谢,急求,在线等!

2024-11-17 13:56:15
推荐回答(1个)
回答1:

#include 
#include 
#include 
int main()
{    
    int a,b,c;    
    scanf("%d%d%d",&a,&b,&c);    
    double k=b*b-4*a*c;    
    if(k<0)    
    {        
        printf("方程无解!");    
     }    
     else    
     {        
         double as=(-1*b+sqrt(k))/2*a;        
         double sd=(-1*b-sqrt(k))/2*a;        
         if(k==0)       
          {            
              printf("方程就有一个解:%lf",as);       
              }       
               else       
                {            
                printf("方程两个解:%lf和%lf",as,sd);       
                 }    
                 }    
                 return 0;
    }