PHP Code:
//Tam giac
#include <stdio.h>
#include <math.h>
main(){
long x1,y1,x2,y2,x3,y3;
while(scanf("%ld%ld%ld%ld%ld%ld",&x1,&y1,&x2,&y2,&x3,&y3)>=1){
//Tinh do dai:
double c[3];
c[0]=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
c[1]=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c[2]=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
//Kiem tra co phai là tam giac
int kq=1;
for(int i=0;i<3;i++){
if(c[i]==c[(i+1)%3]+c[(i+2)%3]) kq=0;
}
//kiem tra tam giac vuong
int v=0;
if(kq!=0)
for(int i=0;i<3;i++){
float m = (float) c[i]*c[i];
float n = (float) (c[(i+1)%3])*(c[(i+1)%3])+(c[(i+2)%3])*(c[(i+2)%3]);
if(m==n) v=1;
}
//kiem tra tam giac can hay deu
int ca=0,d=0;
if(c[0]==c[1]||c[1]==c[2]||c[0]==c[2])
{
ca=1;
if(c[0]==c[1]&&c[1]==c[2]) d=1;
}
//xuat kq:
if(kq==0) printf("0\n");
else{
if(d==1) {
printf("4\n");
ca=0;}
if(ca==1){
printf("3\n");
v=0;}
if(v==1) printf("2\n");
if(ca==0&&v==0&&d==0) printf("1\n");
}
}
}
Leave a comment: