-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path17 rectangle arimethic.cpp
91 lines (76 loc) · 1.52 KB
/
17 rectangle arimethic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<iostream>
#include<math.h>
using namespace std;
class rect
{
int topr[2],topl[2],br[2],bl[2],i;
int h;
int w;
public:
void entdata()
{
cout<<"enter top right cood";
for(i=0;i<2;i++)
{
cin>>topr[i];
}
cout<<"enter bottom left cood";
for(i=0;i<2;i++)
{
cin>>bl[i];
}
topl[0]=bl[0];
topl[1]=topr[1];
br[0]=topr[0];
br[1]=bl[1];
}
void showcoo()
{
cout<<topr[0]<<","<<topr[1]<<endl;
cout<<topl[0]<<","<<topl[1]<<endl;
cout<<bl[0]<<","<<bl[1]<<endl;
cout<<br[0]<<","<<br[1]<<endl;
}
int height()
{
h=topl[1]-bl[1];
// cout<<h<<endl;
return h;
}
int width()
{
w=topr[0]-topl[0];
//cout<<w<<endl;
return w;
}
int ap()
{
cout<<"area is :"<<h*w<<endl;
cout<<"perimeter is:" <<2*(h+w)<<endl;
}
int check(int a,int b)
{
int counter=0;
if(a>bl[0]&&a<br[0])
counter++;
if(b>bl[1]&&b<topl[1])
counter++;
if(counter==2)
{
cout<<"point is inside rectangle";
return 1;
}
counter=0;
return 0;
}
};
int main()
{
rect r1;
r1.entdata();
r1.showcoo();
r1.height();
r1.width();
r1.ap();
r1.check(1,1);
}