-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorcalc.cpp
More file actions
71 lines (61 loc) · 2.9 KB
/
Vectorcalc.cpp
File metadata and controls
71 lines (61 loc) · 2.9 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
66
67
68
69
70
71
/* Operations with vectors. */
#include "stdafx.h"
#include <iostream>
#include "vector.h"
using namespace std;
int main()
{
double x1, y1, x2, y2, r1, r2, multy, number, length;
int select = 0;
menu( select);
cin >> select;
switch (select)
{
case 1:
cout << "Enter the first vector x1 y1" << endl;
cin >> x1 >> y1;
cout << "Enter the second vector x2 y2" << endl;
cin >> x2 >> y2;
r1 = sum(x1, x2);
r2 = sum(y1, y2);
toString(r1, r2);
break;
case 2:
cout << "Enter the first vector x1 y1" << endl;
cin >> x1 >> y1;
cout << "Enter the second vector x2 y2" << endl;
cin >> x2 >> y2;
r1 = substraction(x1, x2);
r2 = substraction(x1, x2);
toString(r1, r2);
break;
case 3:
cout << "Enter the first vector x1 y1" << endl;
cin >> x1 >> y1;
cout << "Enter the second vector x2 y2" << endl;
cin >> x2 >> y2;
multy = x1 * x2 + y1 * y2;
cout << "Multiplication = " << multy << endl;
break;
case 4:
cout << "Enter vector x1 y1" << endl;
cin >> x1 >> y1;
length = sqrt(x1*x1 + y1 * y1);
cout << "Length is " << length << endl;
break;
case 5:
cout << "Enter the vector x1 y1" << endl;
cin >> x1 >> y1;
cout << "Enter the number" << endl;
cin >> number;
r1 = multiply(number, x1);
r2 = multiply(number, y1);
toString(r1, r2);
break;
default:
cout << "Error, restart the program" << endl;
break;
}
system("pause");
return 0;
}