Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <cmath>
- using namespace std;
- int main() {
- cin.tie(0);
- ios_base::sync_with_stdio(0);
- setlocale(LC_ALL, "Russian");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;
- cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy >> Dx >> Dy;
- double ab = sqrt((Bx - Ax) * (Bx - Ax) + (By - Ay) * (By - Ay));
- double bc = sqrt((Cx - Bx) * (Cx - Bx) + (Cy - By) * (Cy - By));
- double cd = sqrt((Dx - Cx) * (Dx - Cx) + (Dy - Cy) * (Dy - Cy));
- double ad = sqrt((Ax - Dx) * (Ax - Dx) + (Ay - Dy) * (Ay - Dy));
- double ac = sqrt(pow(Cx - Ax, 2) + pow(Cy - Ay, 2));
- double bd = sqrt(pow(Bx - Dx, 2) + pow(By - Dy, 2));
- double eps = 1e-10;
- if (abs(ab - bc) < eps && abs(bc - cd) < eps && abs(cd - ad) < eps && abs(ad - ab) < eps) {
- if (abs(ac - bd) < eps) {
- cout << "Квадрат" << endl;
- double p = ab + bc + cd + ad;
- double s = ab * bc;
- cout << "Периметр = " << p << endl;
- cout << "Площадь = " << s << endl;
- }
- else {
- cout << "Ромб" << endl;
- double p = ab + bc + cd + ad;
- double s = 0.5 * ac * bd;
- cout << "Периметр = " << p << endl;
- cout << "Площадь = " << s << endl;
- }
- }
- else if (abs(ab - cd) < eps && abs(bc - ad) < eps && abs(ab - bc) > eps) {
- if (abs(ac - bd) < eps) {
- cout << "Прямоугольник" << endl;
- double p = ab + bc + cd + ad;
- double s = ab * bc;
- cout << "Периметр = " << p << endl;
- cout << "Площадь = " << s << endl;
- }
- else {
- cout << "Параллелограмм" << endl;
- }
- }
- else {
- cout << "Не параллелограмм" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement