Advertisement
FRiTZZY

OR_T3_Z1

Oct 31st, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. /* OR_Tutorijal_3 Zadatak_1*/
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     float a, b, c;
  8.     float x1_re, x1_im;
  9.     float x2_re, x2_im;
  10.     float t, D;
  11.  
  12.     printf("Unesite koeficijente kvadratne jednacine: ");
  13.     scanf("%f %f %f", &a, &b, &c);
  14.  
  15.     D=b*b-4.0f*a*c;
  16.     printf("Rjesenja su: \n");
  17.  
  18.     if (D>0.0f) {
  19.         t=sqrt(D);
  20.  
  21.         x1_re=(-b+t)/(2*a);
  22.         x2_re=(-b-t)/(2*a);
  23.  
  24.         printf(" x1= %f \n", x1_re);
  25.         printf(" x1= %f \n", x2_re);
  26.     }
  27.     else if (D==0.0f) {
  28.         x1_re= -b/(2*a);
  29.  
  30.         printf(" x1=x2= %f \n", x1_re);
  31.     }
  32.     else {
  33.         t=sqrt(-D);
  34.  
  35.         x1_re=-b/(2*a);
  36.         x1_im=t/(2*a);
  37.  
  38.         x2_re=x1_re;
  39.         x2_im=-x1_im;
  40.    
  41.     printf(" x1 = (%f, %f) \n", x1_re, x1_im);
  42.     printf(" x2 = (%f, %f) \n", x2_re, x2_im);
  43.     }
  44.   return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement