文章
84
粉丝
408
获赞
33
访问
877.1k
个人感觉这题有点问题,标准答案似乎忘记判断这个三角形是否满足任意两边之和大于第三边
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
class CPoint{
private:
int x, y;
public:
CPoint(){}
CPoint(int xx, int yy):x(xx),y(yy){}
~CPoint(){}
void setvalue(int xx, int yy) {
x = xx;
y = yy;
}
double operator-(CPoint c);
CPoint operator=(CPoint c);
};
double CPoint::operator-(CPoint c)
{
return sqrt((x-c.x)*(x-c.x) + (y-c.y)*(y-c.y));
}
CPoint CPoint::operator=(CPoint c)
{
return CPoint(c.x, c.y);
}
class CTriangle{
private:
CPoint A, B, C; //点
double a, b, c; //边长
public:
CTriangle(){}
CTriangle(CPoint AA, CPoint BB, CPoint CC):A(AA), B(BB), C(CC){
a = B - C;
b = A - C;
c = A - B;
}
~CTriangle(){}
bool isRight();
double perimeter();
};
bool CTriangle::isRight()
{
double m = a, n = b, l = c, t;
if (m < n) {
t = m;
m = n;
n = t;
}
if (m < l) {
t = m;
m = l;
l = t;
}
//if (m >= n...
登录后发布评论
没问题吧 三个点不重合不共线肯定构成三角形