level 1
#include "stdio.h"#
include "math.h"float fun();void main(){fun();return 0;}float fun(){float a,b,c;float x1,x2;printf("Enter the a,b,and c:\n");scanf("%f,%f,%f",&a,&b,&c);if(b*b-4*a*c>0){printf("方程有两个不等的实数根:\n");x1=(-b+sqrt(b*b-4*a*c))/(2*a);x2=(-b-sqrt(b*b-4*a*c))/(2*a);printf("x1=%f\tx2=%f",x1,x2);}else if(b*b-4*a*c==0){printf("方程有两个相等的实数根:\n");x1=(-b+sqrt(b*b-4*a*c))/(2*a);printf("x1=x2=%f\n",x1);}elseprintf("方程无实数解");}
2008年06月02日 03点06分