#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
double rnd(void)
{
double d;
do {
d
= rand() - RAND_MAX
/ 2.0; } while (d == 0.0);
}
void f(double a, double b, double c, double x)
{
double f;
f = a * x * x + b * x + c;
}
int main()
{
double a, b, c, d, x1, x2;
int i;
for (i = 0; i < 10; i++) {
while (1) {
a = rnd();
b = rnd();
c = rnd();
d = b * b - 4 * a * c;
if (a != 0.0 && d >= 0.0) break;
}
x1
= (-b
+ sqrt(d
)) / (2 * a
); x2
= (-b
- sqrt(d
)) / (2 * a
); printf("a=%f b=%f c=%f\n", a
, b
, c
); f(a, b, c, x1);
f(a, b, c, x2);
}
return 0;
}
I2luY2x1ZGUgPG1hdGguaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCmRvdWJsZSBybmQodm9pZCkKewoJZG91YmxlCWQ7CgoJZG8gewoJCWQgPSByYW5kKCkgLSBSQU5EX01BWCAvIDIuMDsKCX0gd2hpbGUgKGQgPT0gMC4wKTsKCXJldHVybiByYW5kKCkgLyBkOwp9Cgp2b2lkIGYoZG91YmxlIGEsIGRvdWJsZSBiLCBkb3VibGUgYywgZG91YmxlIHgpCnsKCWRvdWJsZQlmOwoKCWYgPSBhICogeCAqIHggKyBiICogeCArIGM7CglwcmludGYoIng9JWYgZj0lZlxuIiwgeCwgZik7Cn0KCmludCBtYWluKCkKewoJZG91YmxlCWEsIGIsIGMsIGQsIHgxLCB4MjsKCWludAlpOwoKCXNyYW5kKHRpbWUoTlVMTCkpOwoJZm9yIChpID0gMDsgaSA8IDEwOyBpKyspIHsKCQl3aGlsZSAoMSkgewoJCQlhID0gcm5kKCk7CgkJCWIgPSBybmQoKTsKCQkJYyA9IHJuZCgpOwoJCQlkID0gYiAqIGIgLSA0ICogYSAqIGM7CgkJCWlmIChhICE9IDAuMCAmJiBkID49IDAuMCkgYnJlYWs7CgkJfQoJCXgxID0gKC1iICsgc3FydChkKSkgLyAoMiAqIGEpOwoJCXgyID0gKC1iIC0gc3FydChkKSkgLyAoMiAqIGEpOwoJCXByaW50ZigiYT0lZiBiPSVmIGM9JWZcbiIsIGEsIGIsIGMpOwoJCWYoYSwgYiwgYywgeDEpOwoJCWYoYSwgYiwgYywgeDIpOwoJfQoJcmV0dXJuIDA7Cn0K