tam giac

int tam_giac(int a,int b,int c)

{

return(a+b>c)&&(a+c>b)&&(b+c>a);

}

int tam_giac_can(int a,int b,int c)

{

return (a==b)||(b==c)||(c==a);

}

int tam_giac_deu(int a,int b,int c)

{

return(a==b)&&(b==c);

}

int tam_giac_vuong(int a,int b,int c)

{

return(a*a=b*b+c*c)||(b*b=a*a+c*c)||(c*c=a*a+b*b);

}

int tam_giac_vuong_can(int a,int b,int c)

{

return tam_giac_vuong(a,b,c)&&tam_giac_can(a,b,c);

}

void kiem_tra_tam_giac(int a,int b,int c)

{

if(!tam_giac(a,b,c))

{

cout<<"Khong tao thanh 3 canh"<<endl;

return ;

}

cout <<"3 so tao thanh";

if(tam_giac_deu(a,b,c))

cout<<"tam giac deu"<<endl;

else

if(tam_giac_vuong_can(a,b,c))

cout<<"tam giac vuong can"<<endl;

else

if(tam_giac_can(a,b,c))

cout<<"tam giac can"<<endl;

else

if(tam_giac_vuong(a,b,c))

cout<<"tam giac vuong"<<endl;

else

cout<<"tam giac"<endl;

}

void main()

{

int a,b,c;

cout<<" Nhap 3 so";cin>>a;cin>>b;cin>>c;

kiem_tra_tam_giac(a,b,c);

}

void kiem_tra_tam_giac_trong_mang(int a[],int n)

{

if(n<3) return n;

for(int i=0;i<n-2;i++)

for(int j=i+1;j<n-1;j++)

for(int k=j+1;k<n;k++)

cout<<"a[i]";cout<<"a[i+1]";cout<<"a[i+2]"

kiem_tra_tam_giac(a[i],a[j],a[k])

}

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: