一元二次方程1

来源:互联网 发布:最新网络语言大全 编辑:程序博客网 时间:2024/05/23 00:25
#include <stdio.h>#include <stdlib.h>int main(){   int a,b,c,disc;   float x1,x2;   printf("Input a,b,c");   scanf("%d%d%d",&a,&b,&c);   disc=b*b-4*a*c;   if(disc>0)   {       x1=-b+sqrt(disc);       x2=-b-sqrt(disc);       printf("x1=%f,x2=%f\n",x1,x2);   }   else if(disc==0)   {       x1=-b+sqrt(disc);       printf("x1=%d\n",x1);   }   else if(disc<0)   {       printf("该方程无解");   }    return 0;}

这里写图片描述

原创粉丝点击