tam giac vuong
/*ktra xem tam giac abc co fai lla tam giac vuong ko*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
typedef struct /*struct(kieu cau truc),typedef :*/
{
float x;
float y;
}diem;
float kc(diem A,diem B)
{
float s;
s=sqrt(pow(A.x-B.x,2)+pow(A.y-B.y,2)); /*pow:ham luy thua.pow(x,y)=x^y*/
return s;
}
int main()
{
diem A,B,C;
float a,b,c;
printf("nhap toa do diem A: ");scanf("%f%f",&A.x,&A.y);
printf("nhap toa do diem B: ");scanf("%f%f",&B.x,&B.y);
printf("nhap toa do diem C: ");scanf("%f%f",&C.x,&C.y);
a=kc(B,C);
b=kc(A,C);
c=kc(A,B);
if(a+b<=c||a+c<=b||b+c<=a)
printf("ABC khong phai tam giac");
else
{
if(a*a+b*b-c*c<=0.001||a*a+c*c-b*b<=0.001||b*b+c*c-a*a<=0.001)
printf("ABC la tam giac vuong");
else
printf("ABC khong phai tam giac vuong");
}
getch();
return 0;
}
Bạn đang đọc truyện trên: AzTruyen.Top