标签:clu style color main mat div turn col bsp
#include<stdio.h> #include<math.h> //定义一元二次方程求根函数函数 void qiugen(float a,float b,float c){ float x,y; if(b*b<4*a*c) printf("该方程没有实根"); else if(b*b==4*a*c){ x=-b/(2*a); printf("该方程有一个根%f",x); } else { x=(-b+sqrt(b*b-4*a*c))/(a*2); y=(-b-sqrt(b*b-4*a*c))/(a*2); printf("该函数有两个根,分别是:%f和%f",x,y); } return 0; } //验证 int main() { float a,b,c; while(1){ printf("\n请输入a,b,c的值:\n"); scanf("%f",&a); scanf("%f",&b); scanf("%f",&c); qiugen(a,b,c); } return 0; }
标签:clu style color main mat div turn col bsp
原文地址:https://www.cnblogs.com/gougouwang/p/11517266.html