Skip to content

Instantly share code, notes, and snippets.

@rkhang7
Created November 15, 2018 11:52
Show Gist options
  • Save rkhang7/88ce56f52bfbd327e9e0aeb1ee0ea751 to your computer and use it in GitHub Desktop.
Save rkhang7/88ce56f52bfbd327e9e0aeb1ee0ea751 to your computer and use it in GitHub Desktop.
// giai pt bac 2
#include <stdio.h>
#include <math.h>
#include <conio.h>
int main(int argc, char *argv[])
{
int a,b,c,d;
printf("a=");scanf("%d",&a);
printf("b=");scanf("%d",&b);
printf("c=");scanf("%d",&c);
d=b*b-4*a*c;
if(a==0)
{
if(b==0)
{
if(c==0) printf("PT co vo so nghiem");
else printf("PT vo nghiem");
}
else printf("Pt co nghiem %f",1.0*(-c)/b);
}
else
{
if(d>0)
{
printf("PT co 2 nghiem la %f va %f",1.0*(-b+sqrt(d))/(2*a),1.0*(-b-sqrt(d))/(2*a));
}
else if(d==0) printf("Pt co nghiem kep la %f",(1.0*(-b))/(2*a));
else printf("PT vo nghiem ");
}
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment