Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- functions.h
- -----------
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- #include <stdlib.h>
- using namespace std;
- #include "figure.h"
- void zada4a();
- ------------
- figure.h
- ------------
- class point{
- private:
- double x;
- double y;
- public:
- point(): x(0), y(0){}
- point(int, int);
- friend class figure;
- friend istream& operator >> (istream& s, point& d);
- };
- class figure{
- private:
- point koor, koor1, koor2, koor3;
- static char nazv[10];
- static int total;
- int t;
- public:
- figure(); //Конструктор по умолчанию
- figure( point kor, point kor1, point kor2, point kor3 );
- figure( const figure&);
- ~figure(){
- total--;
- }
- void proverka(figure&);
- };
- ------------
- main.cpp
- ------------
- #include "functions.h"
- void main(){
- setlocale(0, "RUS");
- zada4a();
- system("pause");
- return;
- }
- ------------
- functions.cpp
- ------------
- #include "functions.h"
- void zada4a(){
- figure a1, a2,a5;
- point a(1,1), b(4,4), c(6,4), d(9,1);
- point aa1(1,1), bb1(2,4), cc1(6,4), dd1(9,1);
- figure ak(a,b,c,d);
- figure ak1(aa1,bb1,cc1,dd1);
- ak.proverka(ak);
- ak1.proverka(ak1);
- figure ab(ak);
- return;
- }
- ------------
- figure.cpp
- ------------
- #include "functions.h"
- point::point(int m_x, int m_y){
- x = m_x;
- y = m_y;
- }
- figure::figure(): koor(0,0), koor1(0,0), koor2(0,0), koor3(0,0){
- total++;
- cout << nazv << " " << total << " ";
- } //Конструктор по умолчанию
- figure::figure( point kor, point kor1, point kor2, point kor3 ){
- koor=kor;
- koor1=kor1;
- koor2=kor2;
- koor3=kor3;
- total++;
- cout << nazv << " " << total<< " ";
- }
- figure::figure( const figure& A ){
- koor=A.koor;
- koor1=A.koor1;
- koor2=A.koor2;
- koor3=A.koor3;
- cout << endl << "Конструктор копирования " << endl;
- }
- istream& operator>>(istream& s, point& d){
- s >> d.x;
- return s;
- }
- void figure::proverka(figure& A){
- koor=A.koor;
- koor1=A.koor1;
- koor2=A.koor2;
- koor3=A.koor3;
- double AC = sqrt(pow(koor.x - koor2.x, 2) + pow(koor.y - koor2.y, 2));
- double BD = sqrt(pow(koor1.x - koor3.x, 2) + pow(koor1.y - koor3.y, 2));
- double AB = sqrt(pow(koor.x - koor1.x, 2) + pow(koor.y - koor1.y, 2));
- double AD = sqrt(pow(koor.x - koor3.x, 2) + pow(koor.y - koor3.y, 2));
- double BC = sqrt(pow(koor1.x - koor2.x, 2) + pow(koor1.y - koor2.y, 2));
- if (AC==BD){
- cout << endl << "Трапеция равнобедренная " << endl;
- double h = sqrt(pow(AB,2)-((pow(BC-AD,2))/4));
- double S = h*(BC+AD)/2;
- cout << "Площадь трапеции - " << S << endl << "Высота трапеции - " << h << endl;
- }
- else{
- cout << endl << "Трапеция не равнобедренная " << endl;
- double Perimetr = AB*2+AD+BC;
- cout << "Периметр трапеции равен " << Perimetr <<endl;
- }
- }
- char figure::nazv[10] = "Трапеция\0";
- int figure::total = 0;
Add Comment
Please, Sign In to add comment