include iostream include conio include math using namespace std class

  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
157
158
159
160
161
162
163
164
165
166
167
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
class point
{
float x,y;
public:
point();
void vvod(float inputX,float inputY);
void vivod();
void r1();
void peremestX(float rx);
void peremestY(float ry);
void r2(point p);
void sravnit(point p);
void polyar();
float getX(){return x;};
float getY(){return y;};
};
point::point()
{
x=y=0;
}
void point::vvod(float inputX,float inputY)
{
x=inputX;
y=inputY;
}
void point:: vivod()
{
cout<<"("<<x<<";"<<y<<");"<<endl;
}
void point::r1()
{
float r;
r=sqrt(x*x+y*y);
cout<<"Rasstoyanie do nachala coordinat = "<<r<<endl;
}
void point::peremestX(float rx)
{
x+=rx;
cout<<"Tekushee polozhenie tochki ";
vivod();
}
void point::peremestY(float ry)
{
y+=ry;
cout<<"Tekushee polozhenie tochki ";
vivod();
}
void point::r2(point p)
{ float r;
r=sqrt((x-p.getX())*(x-p.getX())+(y-p.getY())*(y-p.getY()));
cout<<"Rasstoyznie mezhdu tochkami = "<<r<<endl;
}
void point::sravnit(point p)
{
if (x==p.getX() && y==p.getY())
cout<<"Tochki sovpadayut"<<endl;
else
cout<<"Tochki ne sovpadayut"<<endl;
}
void point::polyar()
{
float e,r;
r=sqrt(x*x+y*y);
e=acos(x/r)*180.0/3.14;
cout<<"Polyarnaya koordinata tochki: ";
cout<<"("<<r<<";"<<e<<");"<<endl;
}
#include <iostream>
#include "point.h"
using namespace std;
int main()
{
int i,n,s;
float inputX, inputY, rx,ry;
const int con=5;
point p[con];
do
{
cout<<"\t Viberite operaciu:"<<endl;
cout<<"1: Zadat' tochku"<<endl;
cout<<"2: Vivesti tochku s nomerom"<<endl;
cout<<"3: Vivesti vse tochki"<<endl;
cout<<"4: Opredelit' rasstoyaie do nachala koordinat"<<endl;
cout<<"5: Peremeshenie tochki po osi X"<<endl;
cout<<"6: Peremeshenie tohki po osi Y"<<endl;
cout<<"7: Opredelit' rassoyanie mezhdu 2 tochkami"<<endl;
cout<<"8: Sravnenie na sovpadenie i nesovpadenie koordinat tochek"<<endl;
cout<<"9: Preobrazovanie dekartovih koordinat v polyarnie"<<endl;
cout<<"0: Vihod iz pogrammi"<<endl;
cin>>s;
switch(s)
{
case 1:
cout<<"Vvedite nomer tochki:";
cin>>i;
cout<<"Zadayte koordinatu tochki x y:";
cin>>inputX;
cin>>inputY;
p[i].vvod(inputX,inputY);
break;
case 2:
cout<<"Vvedite nomer tochki:";
cin>>i;
p[i].vivod();
break;
case 3:
for(i=0;i<con;i++)
p[i].vivod();
break;
case 4:
cout<<"Vvedite nomer tochki:";
cin>>i;
p[i].r1();
break;
case 5:
cout<<"Vvedite nomer tochki:";
cin>>i;
cin>>rx;
p[i].peremestX(rx);
break;
case 6:
cout<<"Vvedite nomer tochki:";
cin>>i;
cin>>ry;
p[i].peremestY(ry);
break;
case 7:
cout<<"Vvedite nomer pervoy tochki:";
cin>>i;
cout<<"Vvedite nomer vtoroy tochki:";
cin>>n;
p[i].r2(p[n]);
break;
case 8:
cout<<"Vvedite nomer pervoy tochki:";
cin>>i;
cout<<"Vvedite nomer vtoroy tochki:";
cin>>n;
p[i].sravnit(p[n]);
break;
case 9:
cout<<"Vvedite nomer tochki:";
cin>>i;
p[i].polyar();
break;
default:
cout<<"Vi vveli neverniy nomer operacii"<<endl;
}
}
while(s!=0);
}