SHOW:
|
|
- or go back to the newest paste.
| 1 | #include<stdio.h> | |
| 2 | #include<conio.h> | |
| 3 | #include<math.h> | |
| 4 | void main() | |
| 5 | {
| |
| 6 | int a,b,c; | |
| 7 | printf("Vvedite a, b, c:\n");
| |
| 8 | scanf("%i %i %i", &a, &b, &c);
| |
| 9 | float d,D; | |
| 10 | d=(b*b)-4*a*c; | |
| 11 | if (d < 0) | |
| 12 | {
| |
| 13 | printf("Korney net");
| |
| 14 | exit(1); | |
| 15 | } | |
| 16 | D=sqrt(d); | |
| 17 | float x1,x1; | |
| 18 | - | x1 = (-b+D)/(2*a); |
| 18 | + | if (a != 0) |
| 19 | - | x2 = (-b-D)/(2*a); |
| 19 | + | |
| 20 | - | printf("x1 = %f; x2 = %f. \n", x1, x2);
|
| 20 | + | x1 = (-b+D)/(2*a); |
| 21 | x2 = (-b-D)/(2*a); | |
| 22 | printf("x1 = %f; x2 = %f. \n", x1, x2);
| |
| 23 | } | |
| 24 | else printf("Eto lineynoe");
| |
| 25 | getch(); | |
| 26 | } |