trojanxem

Untitled

Mar 20th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <conio.h>
  4.  
  5. int main()
  6. {
  7.     float ax2,by,c,x1,x2,x3;
  8.    
  9.     printf("Podaj wzór funkcji kwadratowej: \n");
  10.     printf("W postacie ax^2+by+c.\n");
  11.     scanf("%f%f%f", &ax2, &by,&c);
  12.    
  13.     float delta;
  14.    
  15.     delta = -by*by - 4 * ax2 * c;
  16.    
  17.     if( delta > 0 )
  18.     {
  19.         x1 = ((-by - sqrt(delta)) / 2 * ax2);
  20.         x2 = ((-by + sqrt(delta)) / 2 * ax2);
  21.         printf("Miejsca zerowe to: %f %f\n",x1,x2);
  22.         getch();
  23.         return 0;        
  24.         }
  25.         else if(delta = 0)
  26.         {
  27.              x3 = - by / 2 * ax2;            
  28.              printf("Twoje miejsce zerowe to: %f", x3);
  29.              getch();
  30.              return 0;            
  31.              }
  32.              else
  33.              printf("Delta ujemna. \n");            
  34.              getch();            
  35.              return 0;
  36.        
  37. }
Advertisement
Add Comment
Please, Sign In to add comment