• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 13th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <cmath>
3. #include <time.h>
4.
5.
6. #define LINE 128
7.
8. using namespace std;
9.
10. typedef struct point // структура кординаты
11. {
12.     int x;
13.     int y;
14.     int z;
15. };
16.
17.
18. double Volume(point l1, point l2, point l3)
19. {
20.     return (l1.x * ((l2.y*l3.z) - (l3.y*l2.z))) - (l2.x * ((l1.y*l3.z) - (l1.z*l3.y))) + (l3.x * ((l1.y*l2.z) - (l2.y*l1.z))) / 6.0;
21. }
22.
23. int main()
24. {
25.     srand(time(0));
26.     point listofpoints[4]; // МАССИВ точек
27.
28.     for (size_t i = 0; i < 4; i++)
29.     {
30.         /*--------------Генерация--------------*/
31.         point temp;
32.         temp.x = -LINE + (rand() % (2*LINE)); temp.y = -LINE + (rand() % (2*LINE)); temp.z = -LINE + (rand() % (2*LINE));
33.         cout << i+1 << ". " << temp.x << " " << temp.y << " " << temp.z << endl; // Вывод в терминал кординат
34.         listofpoints[i] = temp;
35.         /*--------------Генерация--------------*/
36.     }
37.
38.     point l1,l2,l3;
39.
40.     l1.x = listofpoints[1].x - listofpoints[0].x; l1.y = listofpoints[1].y - listofpoints[0].y; l1.z = listofpoints[1].z - listofpoints[0].z;
41.     l2.x = listofpoints[2].x - listofpoints[0].x; l2.y = listofpoints[2].y - listofpoints[0].y; l2.z = listofpoints[2].z - listofpoints[0].z;
42.     l3.x = listofpoints[3].x - listofpoints[0].x; l3.y = listofpoints[3].y - listofpoints[0].y; l3.z = listofpoints[3].z - listofpoints[0].z;
43.
44.
45.     cout << abs(Volume(l1,l2,l3)) << endl; // вывод объема
46.
47.     cin >> l1.x;
48.
49.
50.     return 0;
51. }
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.
Not a member of Pastebin yet?