1 solutions
-
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
Information
- ID
- 16624
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By