-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork44.cpp
More file actions
61 lines (56 loc) · 1.19 KB
/
Copy pathwork44.cpp
File metadata and controls
61 lines (56 loc) · 1.19 KB
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
#include<iostream>
#include<cmath>
using namespace std;
template<typename T>
class Vector
{
private:
T x, y, z;
public:
Vector(T a=0,T b=0 ,T c=0)
{
x = a;
y = b;
z = c;
}
Vector operator+(Vector n) const
{
return Vector(x + n.x, y + n.y, z + n.z);
}
bool operator==(const Vector& n) const
{
const double eps = 1e-6;
return (fabs(x - n.x) < eps &&
fabs(y - n.y) < eps &&
fabs(z - n.z) < eps);
}
friend Vector operator*(T scalar, const Vector& n)
{
return Vector(scalar * n.x, scalar * n.y, scalar * n.z);
}
friend istream& operator>>(istream& is,Vector &n)
{
is >> n.x >> n.y >> n.z;
return is;
}
friend ostream& operator<<(ostream& os,const Vector &n)
{
os << n.x << " " << n.y << " " << n.z;
return os;
}
};
int main()
{
double a, b, c;
std::cin >> a >> b >> c;
Vector<double> v1(a, b, c), v2(v1), v3, v4;
double d;
std::cin >> d;
v4 = d * v1 + v2;
std::cout << v4 <<std::endl;
Vector<double> v;
std::cin >> v;
int flag = (v4 == v);
std::cout << flag << std::endl;
return 0;
}