求c语言大神指教,谢谢

如题所述

#include <stdio.h>
#include <math.h>
typedef struct point {
double x,y;
}POINT;
double disdence(POINT a,POINT b) {
return sqrt((b.x - a.x)*(b.x - a.x)+(b.y - a.y)*(b.y - a.y));
}

POINT GetPoint() {
POINT P;
scanf("%lf %lf",&P.x,&P.y);
return P;
}

int main() {
int T;
double a,b,c;
POINT pa,pb,pc;
printf("T = ");
scanf("%d",&T);
while(T--) {
printf("点a坐标:");
pa = GetPoint();
printf("点b坐标:");
pb = GetPoint();
printf("点c坐标:");
pc = GetPoint();
a = disdence(pb,pc);
b = disdence(pa,pc);
c = disdence(pb,pa);
if((a + b < c) ||(b + c < a)||(c + a < b)) printf("不能构成三角形!\n");
else if(a == b && b == c && c == a) printf("等边三角形!\n");
else if((a*a + b*b == c*c)|| (b*b + c*c == a*a) ||(c*c + a*a == b*b)) printf("直角三角形!\n");
else printf("普通三角形!\n");
}
return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-01-10
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef struct
{
double x;
double y;
}coor;
int main()
{
coor p[3];
double side[4];
int i,j,k;
for(i=0;i<3;i++)scanf("%lf%lf",&p[i].x,&p[i].y);//分别输入三个点的坐标
for(i=0;i<3;i++)
{
j=(i+1)%3;
side[i]=pow((pow(p[i].x-p[j].x,2))+(pow(p[i].y-p[j].y,2)),0.5);
//计算三边长度
}
for(i=k=0;i<3;i++)k = (side[i]>side[k])?i:k;
for(side[3]=0,i=0;i<3;i++)
{
if(i==k)continue;
side[3]+=pow(side[i],2);
}
side[3] = sqrt(side[3]);
{
if(side[k]>side[3])
{
printf("锐角三角形");
}
else if(side[k]<side[3])
{
printf("钝角三角形");
}
else
{
printf("直角三角形");
}
}
return 0;
}

本回答被网友采纳
相似回答