-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.cpp
More file actions
54 lines (44 loc) · 1020 Bytes
/
vector.cpp
File metadata and controls
54 lines (44 loc) · 1020 Bytes
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
#include "stdafx.h"
#include "vector.h"
#include <iostream>
using namespace std;
void print_error()
{
cout << "Error, restart the program!" << endl;
}
void print_menu(int select)
{
cout << "Enter operation" << endl;
cout << "__________________________________" << endl;
cout << "1. Sum" << endl;
cout << "2. Substraction" << endl;
cout << "3. Multiplication vector & vector" << endl;
cout << "4. Length of vector" << endl;
cout << "5. Multiplication vector & number" << endl;
cout << "__________________________________" << endl;
}
void toString(vector *v)
{
cout << "Your vector is (" << v->x << ';' << v->y << ')' << endl;
}
vector sum(vector *v1, vector *v2)
{
vector v;
v.x = v1->x + v2->x;
v.y = v1->x + v2->y;
return v;
}
vector substraction(vector *v1, vector *v2)
{
vector v;
v.x = v1->x - v2->x;
v.y = v1->x - v2->y;
return v;
}
vector multiply(vector *v1, double n)
{
vector v;
v.x = v1->x * n;
v.y = v1->y * n;
return v;
}