Untitled
TEXT
views 13
,
size 3508 b
``````Point::Point(){
x=0;
y=0;
}
Point::Point(double x_, double y_){
x=x_;
y=y_;
}
Point::Point(const Point& p){
x = p.x;
y = p.y;
}
Triangle::Triangle(Point A, Point B, Point C)
{
p1 = A;
p2 = B;
p3 = C;
}
double Triangle::getPerimeter() const
{
return sqrt(pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2)) + sqrt(pow((p2.x - p3.x), 2) + pow((p2.y - p3.y), 2)) + sqrt(pow((p3.x - p1.x), 2) + pow((p3.y - p1.y), 2));
}
double Triangle::getArea() const
{
double p = getPerimeter()/2;
return sqrt(p*(p - sqrt(pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2)))*(p - sqrt(pow((p2.x - p3.x), 2) + pow((p2.y - p3.y), 2)))*(p - sqrt(pow((p3.x - p1.x), 2) + pow((p3.y - p1.y), 2))));
}

class Time {
private:
int hours;
int minutes;
int seconds;
public:
int hour() {
return hours;
}

int minute() {
return minutes;
}

int second() {
return seconds;
}

Time() {
hours = 0;
minutes = 0;
seconds = 0;
}
Time(int hour_, int minute_, int second_)
{
int x = hour_*3600 + minute_*60 + second_;

if (second_ > 59 || minute_ > 59)
{
hour_ = x/3600;
minute_ = x % 3600 / 60;
second_ = x % 3600 % 60;
}
hours = hour_;
minutes = minute_;
seconds = second_;
}

Time(int hour_, int minute_)
{
hours = hour_;
minutes = minute_;
seconds = 0;
}

Time(int hour_)
{
hours = hour_;
minutes = 0;
seconds = 0;
}

friend ostream& operator<< (ostream& os, const Time& tm)
{
if (tm.hours < 10) os << "0" << tm.hours << ":";
else os << tm.hours << ":";

if (tm.minutes < 10) os << "0" << tm.minutes << ":";
else os << tm.minutes << ":";

if (tm.seconds < 10) os << "0" << tm.seconds;
else os << tm.seconds;

return os;
}

friend bool operator< (const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) < (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}

friend bool operator> (const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) > (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}

friend bool operator<=(const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) <= (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}

friend bool operator>=(const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) >= (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}

friend bool operator==(const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) == (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}

friend bool operator!=(const Time& tm1 , const Time& tm2)
{
if ((tm1.hours*3600 + tm1.minutes*60 + tm1.seconds) != (tm2.hours*3600 + tm2.minutes*60 + tm2.seconds)) return 1;
else return 0;
}
};``````