#include<stdio.h> #include<math.h> #define MIN 0.00001 int main() { float a,b,c; scanf("%f %f %f",&a,&b,&c); if((a<MIN)&&(a>-MIN)) { printf("不是一元二次函数"); } else { float disc=b*b-4*a*c; if((disc<MIN)&&(disc>-MIN)) { printf("方程有两个相等的实根:\n"); printf("x1=x2=%f\n",-b/(2*a)); } else if(disc>0.0) { printf("有两个不相等实根:\"); printf("x1=%f\n",(-b+sqrt(disc))/(2*a)); printf("x2=%f\n",(-b-sqrt(disc))/(2*a)); } else { printf("有一组共轭复根\n"); } } return 0; }
时间: 2024-10-14 01:53:14