Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <math.h>
- using namespace std;
- class Triangle {
- protected:
- int x1, y1;
- int x2, y2;
- int x3, y3;
- double a, b, c;
- public:
- Triangle() {
- x1 = 0; y1 = 0;
- x2 = 0; y2 = 1;
- x3 = 1; y3 = 0;
- a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
- b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
- c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
- }
- Triangle(int x1, int y1, int x2, int y2, int x3, int y3) {
- this->x1 = x1; this->y1 = y1;
- this->x2 = x2; this->y2 = y2;
- this->x3 = x3; this->y3 = y3;
- a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
- b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
- c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
- }
- bool is() {
- return ((a + b > c) && (b + c > a) && (c + a > b));
- }
- double P() {
- return a + b + c;
- }
- double S() {
- double p = (a + b + c) / 2.0;
- return sqrt(p * (p - a) * (p - b) * (p - c));
- }
- double geta() {
- return a;
- }
- double getb() {
- return b;
- }
- double getc() {
- return c;
- }
- void print() {
- double ugol1 = acos((a * a + b * b - c * c) / (2 * a * b));
- double ugol2 = acos((c * c + b * b - a * a) / (2 * c * b));
- double ugol3 = acos((c * c + a * a - b * b) / (2 * c * a));
- cout << "Triangle:\n"
- << "\t" << "len1: " << a << "\n"
- << "\t" << "len2: " << b << "\n"
- << "\t" << "len3: " << c << "\n"
- << "\t" << "ugol1: " << ugol1 << "\n"
- << "\t" << "ugol2: " << ugol2 << "\n"
- << "\t" << "ugol3: " << ugol3 << "\n"
- << "\t" << "P: " << P() << "\n"
- << "\t" << "S: " << S() << "\n";
- }
- ~Triangle() {}
- };
- class IsoTriangle : public Triangle {
- public:
- IsoTriangle() {
- x1 = 0; y1 = 0;
- x2 = 0; y2 = 1;
- x3 = 1; y3 = 0;
- a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
- b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
- c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
- }
- IsoTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
- this->x1 = x1; this->y1 = y1;
- this->x2 = x2; this->y2 = y2;
- this->x3 = x3; this->y3 = y3;
- a = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
- b = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
- c = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
- }
- bool is_iso() {
- return (a == b || b == c || c == a);
- }
- ~IsoTriangle() {}
- };
- int main(void) {
- int n;
- int m;
- cin >> n >> m;
- Triangle *arr = new Triangle[n];
- int x1, y1;
- int x2, y2;
- int x3, y3;
- for (int i = 0; i < n; ++ i) {
- cout << "Triangle" << i << endl;
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
- arr[i] = Triangle(x1, y1, x2, y2, x3, y3);
- }
- IsoTriangle mx;
- bool flag = false;
- for (int i = 0; i < m; ++ i) {
- cout << "IsoTriangle" << i << endl;
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
- IsoTriangle tmp = IsoTriangle(x1, y1, x2, y2, x3, y3);
- if (!tmp.is_iso()) {
- cout << "Error\n";
- i --;
- }
- else {
- if (!flag) {
- flag = true;
- mx = tmp;
- }
- else {
- if (tmp.S() > mx.S())
- mx = tmp;
- }
- }
- }
- for (int i = 0; i < n; ++ i) {
- for (int j = 0; j < n; ++ j) {
- if (i != j) {
- double d = arr[i].geta() / arr[j].geta();
- if (arr[i].getb() / arr[j].getb() == d && arr[i].getc() / arr[j].getc() == d) {
- cout << "Podob:\n";
- arr[i].print();
- arr[j].print();
- cout << endl;
- }
- }
- }
- }
- mx.print();
- delete [] arr;
- }
Add Comment
Please, Sign In to add comment