Advertisement
huyhung94

GPT bậc 2

Jan 7th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. GPT bậc 2.
  2. #include<stdio.h>
  3. #include<conio.h>
  4. #include<math.h>
  5. void gpt(float a, float b, float c){
  6.     float delta,x1,x2;
  7.    if (a==0)
  8.         if(b==0)
  9.             if(c==0)
  10.                 printf("Ptrinh co vo so nghiem.");
  11.             else
  12.                 printf("Phuong trinh vo nghiem.");
  13.         else
  14.             printf("x = %0.2f",c/b);
  15.    else{
  16.         delta = b*b-4*a*c;
  17.         if (delta<0)
  18.             printf("Phuong trinh vo nghiem.");
  19.         else
  20.             if(delta>0)
  21.                 printf("x1 = %0.2f    x2 = %0.2f ",(-b+sqrt(delta))/(2*a),
  22.                 (-b-sqrt(delta))/(2*a));
  23.             else
  24.                 printf("x = %0.2f ",(-b)/(2*a));
  25.    }
  26. }
  27. int main(){
  28. gpt(1,5,6);
  29. getch();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement