detective1711

Giải PT Bậc 2 TQ

Oct 19th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Giai PT bac 2 //By CQH
  2. //Trình Công Quang //MSSV: 12520344
  3.  
  4.  
  5. # include <stdio.h>
  6. # include <conio.h>
  7. # include <math.h>
  8.  
  9. void main ()
  10.  
  11. {
  12.     float a,b,c;
  13.     float delta;
  14.     printf("\nNhap cac he so cua PT:\n");
  15.     printf("\na = ");
  16.     scanf("%f",&a);
  17.     printf("\nb = ");
  18.     scanf("%f",&b);
  19.     printf("\nc = ");
  20.     scanf("%f",&c);
  21.    
  22.     if (a!=0)
  23.         {
  24.             delta=b*b-4*a*c;
  25.            
  26.         if (delta > 0)
  27.             printf ("\nPT co 2 nghiem phan biet : x1 = %.2f va x2 = %.2f\n\n", (-b+sqrt(delta))/(2*a), (-b-sqrt(delta))/(2*a) );
  28.         else if (delta == 0 )
  29.             printf ("\nPT co nghiem kep : x1 = x2 = %.2f\n\n", (-b)/(2*a ));
  30.         else
  31.             printf ("\nPT vo nghiem!\n\n");
  32.         }
  33.     else
  34.         {
  35.             if (b==0)
  36.                 {
  37.                     if (c==0)
  38.                     printf("\nPT vo so nghiem\n\n");
  39.                     else
  40.                     printf("\nPT vo nghiem\n\n");
  41.                 }
  42.             else
  43.                 printf("\nPT co 1 nghiem: x = %.2f\n\n", -c/b);
  44.         }
  45.         printf("\nBam phim bat ki de thoat........... ");
  46.         getch();   
  47. }
  48. int pressout(int argc, char *argv[])
  49. {
  50.     getchar();
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment