• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

Kiparisss Dec 15th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <math.h>
3. #include <locale.h>
4.
5. void inputVector(float* x) {
6.
7.     for (int i = 0; i < 2; i++)
8.         std::cin >> x[i];
9.
10. }
11.
12. float getMin(float* x) {
13.
14.     if (x[0] < x[1]) {
15.         return x[0];
16.     }
17.     else {
18.         return x[1];
19.     }
20.
21. }
22.
23. float calcScl(float* x, float* y) {
24.
25.     return x[0] * y[0] + x[1] * y[1];
26.
27. }
28.
29. void main() {
30.
31.     setlocale(LC_CTYPE, "RUSSIAN");
32.
33.     float x[2], y[2], z[2];
34.     float* a[3];
35.
36.     std::cout << "Введите (координаты через пробел) x: ";
37.     inputVector(x);
38.     std::cout << "Введите y: ";
39.     inputVector(y);
40.     std::cout << "Введите z: ";
41.     inputVector(z);
42.
43.     if (getMin(x) > getMin(y) && getMin(x) > getMin(z)) {
44.
45.         a[0] = x;
46.         a[1] = y;
47.         a[2] = z;
48.
49.     }
50.
51.     if (getMin(y) > getMin(x) && getMin(y) > getMin(z)) {
52.
53.         a[0] = y;
54.         a[1] = x;
55.         a[2] = z;
56.
57.     }
58.
59.     if (getMin(z) > getMin(y) && getMin(z) > getMin(x)) {
60.
61.         a[0] = z;
62.         a[1] = x;
63.         a[2] = y;
64.
65.     }
66.
67.     std::cout << "(a, a) - (b, c) = " << (calcScl(a[0], a[0]) - calcScl(a[1], a[2])) << '\n';
68.     std::cin >> a[0][0];
69.
70.
71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top