再弱弱的问下(while(1))
写程序时,也许与我用的编译器仍是TC for windows有关吧长调用scanf,再输入一个数据后用printf回显,但只能闪一下,
有老师看过后加了句while(1)
即可
不知为何
while在判断什么
望回答,谢
[[it] 本帖最后由 wangweinoo1 于 2008-9-21 12:20 编辑 [/it]]
/* Note:Your choice is C IDE */ #include "stdio.h" #include "math.h" main() { float a,b,c,disc,x1,x2,term1,term2; printf("Enter a,b,c:\n"); scanf("%f,%f,%f",&a,&b,&c); if(fabs(a)<=1e-7) printf("is not quardratic"); else disc=b*b-4*a*c; if(fabs(disc)<=1e-7) printf("two equal roots are:%7.2",-b/(2*a)); else { if(disc>1e-7) { x1=(-b+sqrt(disc))/(2*a); x2=(-b-sqrt(disc))/(2*a); printf("two real roots are:%7.2f,%7.2f",x1,x2); } else { term1=-b/(2*a); term2=sqrt(-disc)/(2*a); printf("two complex roots:\n"); printf("%7.2f+%7.2fi\n",term1,term2); printf("%7.2f-%7.2fi\n",term1,term2); } } while(1); }