1 条题解
-
0
C :
#include<stdio.h> #include<math.h> int main() { int a, b, c; double res1, res2; scanf("%d%d%d", &a, &b, &c); res1 = ((-b) + sqrt(pow(b, 2) - (4 * a*c))) / ((2)*a); res2 = ((-b) - sqrt(pow(b, 2) - (4 * a*c))) / ((2)*a); if (sqrt(pow(b, 2) - (4 * a*c))==0) printf("%.3lf\n", res1); else if (sqrt(pow(b, 2) - (4 * a*c)) > 0) printf("%.3lf %.3lf\n", res1, res2); else printf("NOANSWER\n"); return 0; }
Pascal :
var a,b,c,d:double; begin readln(a,b,c); if(a=0) then begin writeln('不是二次方程');exit;end; d:=b*b-4*a*c; if(d<0) then begin writeln('NOANSWER');exit;end; d:=sqrt(d); if(d=0) then begin writeln(-b/(2*a):0:3);exit;end; writeln((-b+d)/(2*a):0:3,' ',(-b-d)/(2*a):0:3); end.
- 1
信息
- ID
- 1234
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者