-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectors.cpp
More file actions
65 lines (52 loc) · 2.52 KB
/
vectors.cpp
File metadata and controls
65 lines (52 loc) · 2.52 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
62
63
64
65
/* Operations with vectors. */
#include "stdafx.h"
#include <iostream>
#include "vector.h"
using namespace std;
int main()
{
double multy, number, length;
int select = 0;
vector v1, v2, v3;
print_menu(select);
cin >> select;
switch (select)
{
case 1:
cout << "Enter the vector's cooridnates x1 y1 x2 y2" << endl;
cin >> v1.x >> v1.y >> v2.x >> v2.y;
v3 = sum(&v1, &v2);
toString(&v3);
break;
case 2:
cout << "Enter the vector's cooridnates x1 y1 x2 y2" << endl;
cin >> v1.x >> v1.y >> v2.x >> v2.y;
v3 = substraction(&v1, &v2);
toString(&v3);
break;
case 3:
cout << "Enter the vector's cooridnates x1 y1 x2 y2" << endl;
cin >> v1.x >> v1.y >> v2.x >> v2.y;
multy = v1.x * v2.x + v1.y * v2.y;
cout << "Multiplication = " << multy << endl;
break;
case 4:
cout << "Enter the vector x1 y1" << endl;
cin >> v1.x >> v1.y;
length = sqrt(v1.x*v1.x + v1.y*v1.y);
cout << "Length is " << length << endl;
break;
case 5:
cout << "Enter the vector's coordinates x1 y1" << endl;
cin >> v1.x >> v1.y;
cout << "Enter the number" << endl;
cin >> number;
v3 = multiply(&v1, number);
toString(&v3);
break;
default:
print_error();
break;
}
system("pause");
}