Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //lr2.3
- // CPP libs
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <algorithm>
- #include <memory>
- #include <random>
- //#include <vector>
- //#include <stack>
- //#include <exception>
- //#include <stdexcept>
- // C libs
- #include <cmath>
- #include <cctype>
- #include <cstring>
- #include <ctime>
- //#include <cstdint>
- //#include <cstdlib>
- //#include <cstdio>
- //#include <unistd.h>
- using namespace std;
- struct BinKor;
- //Груз ::= Гирька | БинКор
- struct Load {
- bool isWeight;
- union {
- int weight;
- BinKor* binKor;
- } data;
- };
- //Плечо ::= (Длина Груз)
- struct Side {
- short length;
- Load* load;
- };
- //БинКор ::= (Плечо Плечо)
- struct BinKor {
- Side* right;
- Side* left;
- };
- short Length (const BinKor bk) {
- short result = 0;
- if (bk.right) {
- result += bk.right->length;
- if (bk.right->load && !bk.right->load->isWeight) result += Length(*bk.right->load->data.binKor);
- }
- if (bk.left) {
- result += bk.left->length;
- if (bk.left->load && !bk.left->load->isWeight) result += Length(*bk.left->load->data.binKor);
- }
- return result;
- }
- //todo добавить ввод
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement