Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void gr2eq()
- {
- int a, b, c;
- scanf("%d%d%d", &a, &b, &c);
- int delta = b * b - 4 * a * c;
- float rootDelta;
- float realPart;
- if (delta == 0)
- printf("x1 = x2 = %.2f\n", -b / 2.0f / a);
- else if (delta > 0)
- {
- rootDelta = sqrt(delta);
- printf("x1 = %.2f, x2 = %.2f\n", (-b + rootDelta) / 2 / a, (-b - rootDelta) / 2 / a);
- }
- else
- {
- // camel case
- realPart = -b / (2.0f * a);
- rootDelta = sqrt(-delta);
- rootDelta /= 2 * a;
- rootDelta = rootDelta / 2 / a;
- printf("x1 = %.2f + %.2fi, x2 = %.2f + %.2fi\n",
- realPart, rootDelta, realPart, -rootDelta);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment