Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. #include <math.h>
  2. #include  <stdio.h>
  3. int main(){        
  4.     float a,b,c, x, d, ds, pom, x1, x2;        
  5.     printf("a=");        
  6.     scanf("%f",&a);        
  7.     printf("b=");        
  8.     scanf("%f",&b);        
  9.     printf("c=");        
  10.     scanf("%f",&c);                      
  11.     if(a==0)        
  12.     {          
  13.         if(b==0)          
  14.         {                
  15.             if(c==0)            
  16.             {                
  17.                 printf("tozsamosc\n");            
  18.             } else            
  19.             {                
  20.                 printf("sprzecznosc\n");            
  21.             }          
  22.         }          
  23.         else          
  24.         {            
  25.             x=-c/b;            
  26.             printf("x=%f\n",x);          
  27.         }  
  28.     }        
  29.     else          
  30.     {          
  31.         d=b*b-4*a*c;          
  32.         if(d>0)          
  33.         {              
  34.             ds=sqrt(d)/(2*a);            
  35.             pom=(-b)/(2*a);            
  36.             x1=pom-ds;            
  37.             x2=pom+ds;
  38.             printf("x1=%f, x2=%f\n", x1, x2);          
  39.         }            
  40.         else if(d==0)          
  41.         {            
  42.             x=(-b)/(2*a);            
  43.             printf("x=%f\n", x);          
  44.         }          
  45.         else          
  46.         {            
  47.             printf("nie ma miejsc zerowych");  
  48.         }        
  49.     }            
  50.     getchar();        
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement