Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class Triangle {
- private:
- int x1 = 0, x2 = 0, x3 = 0, x4 = 0, y1 = 0, y2 = 0, y3 = 0, y4 = 0;
- public:
- Triangle() {}
- Triangle(int _x1, int _x2, int _x3, int _x4, int _y1, int _y2, int _y3, int _y4) {
- x1 = _x1;
- x2 = _x2;
- x3 = _x3;
- x4 = _x4;
- y1 = _y2;
- y3 = _y3;
- y4 = _y4;
- }
- double GetAB() {
- return sqrt(pow(y2 - y1, 2) + pow(x2 - x1, 2));
- }
- double GetBC() {
- return sqrt(pow(y3 - y2, 2) + pow(x3 - x2, 2));
- }
- double Parimeter() {
- return 2 * (GetAB() + GetBC());
- }
- double Square() {
- return GetAB() * GetBC();
- }
- };
- int main()
- {
- int x1 = -3, x2 = -3, x3 = 5, x4 = 5, y1 = -1, y2 = 3, y3 = 3, y4 = -1;
- Triangle triangle(x1, x2, x3, x4, y1, y2, y3, y4);
- cout << "S = " << triangle.Square() << endl;
- cout << "P = " << triangle.Parimeter() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment