Advertisement
caxapexac

Untitled

Sep 17th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. //lr2.3
  2. // CPP libs
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <algorithm>
  7. #include <memory>
  8. #include <random>
  9. //#include <vector>
  10. //#include <stack>
  11. //#include <exception>
  12. //#include <stdexcept>
  13.  
  14. // C libs
  15. #include <cmath>
  16. #include <cctype>
  17. #include <cstring>
  18. #include <ctime>
  19. //#include <cstdint>
  20. //#include <cstdlib>
  21. //#include <cstdio>
  22. //#include <unistd.h>
  23.  
  24. using namespace std;
  25.  
  26. struct BinKor;
  27.  
  28. //Груз ::= Гирька | БинКор
  29. struct Load {
  30.     bool isWeight;
  31.     union {
  32.         int weight;
  33.         BinKor* binKor;
  34.     } data;
  35. };
  36.  
  37. //Плечо ::= (Длина Груз)
  38. struct Side {
  39.     short length;
  40.     Load* load;
  41. };
  42.  
  43. //БинКор ::= (Плечо Плечо)
  44. struct BinKor {
  45.     Side* right;
  46.     Side* left;
  47. };
  48.  
  49. short Length (const BinKor bk) {
  50.     short result = 0;
  51.     if (bk.right) {
  52.         result += bk.right->length;
  53.         if (bk.right->load && !bk.right->load->isWeight) result += Length(*bk.right->load->data.binKor);
  54.     }
  55.     if (bk.left) {
  56.         result += bk.left->length;
  57.         if (bk.left->load && !bk.left->load->isWeight) result += Length(*bk.left->load->data.binKor);
  58.     }
  59.     return result;
  60. }
  61.  
  62. //todo добавить ввод
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement