-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
156 lines (126 loc) · 2.81 KB
/
main.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
class point
{
float x, y;
public:
point(float a = 0, float b = 0){
x = a;
y = b;
}
float getX(){
return x;
}
void setX(float a){
x = a;
}
float getY(){
return y;
}
void setY(float a){
y = a;
}
void afficher(){
cout << "(" << x << "," << y << ")";
}
void translation (float a){
x += a;
y += a;
}
bool comparer(point p){
if(x == p.x && y == p.y)
return true;
return false;
}
float distance(point p){
return sqrt(pow(x - p.x , 2) + pow(y - p.y , 2));
}
};
class cercle{
float r;
point centre;
public:
cercle(float a, point p){
r = a;
centre = p;
}
cercle(float a, float x, float y){
r = a;
centre.setX(x);
centre.setY(y);
}
void afficher(){
cout << "Affichage du cercle : ";
cout<<"Le rayon est: " << r << endl;
cout << "Le centre est : ";
centre.afficher();
cout<<endl<<"-----"<<endl;
}
float getRayon(){
return r;
}
void setRayon(float a){
r = a;
}
point getCentre(){
return centre;
}
void translation(float a){
centre.translation(a);
}
float surface(){
return r * r * 3.14;
}
float perimetre(){
return 2 * 3.14 * r;
}
bool egalite(cercle c){
return (c.r == r and centre.comparer(c.centre));
}
bool appartenance(point p){
if(centre.distance(p) <= r){
return true;
}
return false;
}
};
int main()
{
point p(10, 10);
cercle c(1, p);
c.afficher();
cout << "Perimetre: " << c.perimetre() << endl
<< "Surface: " << c.surface() << endl;
c.setRayon(c.getRayon() * 2);
cout << "Apres doublement du rayon : " << endl
<< "Perimetre: " << c.perimetre() << endl
<< "Surface: " << c.surface() << endl;
c.translation(-10);
point p1(1, 1);
cout << "Le point : ";
p1.afficher();
if(c.appartenance(p1)){
cout << " est a l'interieur du cercle" << endl;
}
else{
cout << " est a l'exterieur du cercle" << endl;
}
point p2(3, 3);
cout << "Le point : ";
p2.afficher();
if(c.appartenance(p2)){
cout << "est a l'interieur du cercle" << endl;
}
else{
cout << "est a l'exterieur du cercle" << endl;
}
cercle c2(2, 0, 0);
if(c.egalite(c2)){
cout << "Les deux cercles sont identiques" << endl;
}
else
cout << "Les deux cercles ne sont pas identiques" << endl;
return 0;
}