Guest User

Untitled

a guest
Apr 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "conio.h"
  3. #include "math.h"
  4.  
  5. int a, b, c;
  6. float discr, x1, x2;
  7.  
  8.  
  9. int get_var() {
  10.     printf("Vvedite A:");
  11.     scanf("%d",&a);
  12.     printf("Vvedite B:");
  13.     scanf("%d",&b);
  14.     printf("Vvedite C:");
  15.     scanf("%d",&c);
  16.     return a, b, c;
  17. }
  18.  
  19. float get_discr() {
  20.     discr = b*b-4*a*c;
  21.     return discr;
  22. }
  23.  
  24. float calc_x() {
  25.     x1=(-b - sqrt(discr))/(2*a);
  26.     x2=(-b + sqrt(discr))/(2*a);
  27.     return x1, x2;
  28. }
  29.  
  30. int main() {
  31.     get_var();
  32.     if ( a == 0) {
  33.         printf("A raven 0!");
  34.         return(-2);
  35.     }
  36.     else {
  37.         /*printf("A ravno %d\n",a);
  38.         printf("B ravno %d\n",b);
  39.         printf("C ravno %d\n",c);*/
  40.         get_discr();
  41.         if ( discr < 0 ) {
  42.             printf("Net reshenij, D<0");
  43.             return(-1);
  44.         }
  45.         else {
  46.         calc_x();
  47.         printf("x1 raven: %f\n", x1);
  48.         printf("x2 raven: %f\n", x2);
  49.         }
  50.     }
  51.     getch();
  52.    
  53. }
Add Comment
Please, Sign In to add comment