diff --git a/LICENSE b/LICENSE index 261eeb9..abebc40 100644 --- a/LICENSE +++ b/LICENSE @@ -35,7 +35,7 @@ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). + (an example is provided in the Appword_endix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the @@ -116,7 +116,7 @@ of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided + or as an addword_endum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. @@ -169,19 +169,19 @@ License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability + defword_end, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS + WORD_END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. + APPWORD_ENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a + comment syntax for the file format. We also recommword_end that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. diff --git a/homework_01/task_01/src/utils.cpp b/homework_01/task_01/src/utils.cpp index a6989bd..efb8022 100644 --- a/homework_01/task_01/src/utils.cpp +++ b/homework_01/task_01/src/utils.cpp @@ -1,7 +1,40 @@ #include "utils.hpp" +#include #include std::vector SplitString(const std::string& data) { - return {}; + std::vector out; + size_t word_start; + size_t word_end = 0; + bool in_brackets = false; + size_t opening_bracket = 0; + + while ((word_start = data.find_first_not_of(' ', word_end)) != std::string::npos) + { + if (data[word_end]==')'){ + in_brackets = false; + word_end += 1; + out.push_back(data.substr(opening_bracket, word_end - opening_bracket)); + continue; + } + if (in_brackets == 1){ + word_end += 1; + continue; + } + if (data[word_start]=='('){ + opening_bracket = word_start; + in_brackets = 1; + continue; + } + if (data[word_start]=='\t'){ + word_start += 1; + } + word_end = data.find(' ', word_start); + if (data.find('\t', word_start) < data.find(' ', word_start)){ + word_end = data.find('\t', word_start); + } + out.push_back(data.substr(word_start, word_end - word_start)); + } + return out; } diff --git a/homework_01/task_02/src/utils.cpp b/homework_01/task_02/src/utils.cpp index ebc7ffc..d32b266 100644 --- a/homework_01/task_02/src/utils.cpp +++ b/homework_01/task_02/src/utils.cpp @@ -3,5 +3,23 @@ #include int Calculate(const std::string& data) { - return 0; -} + int a, b, result; + result = 0; + a = data[0]-'0'; + b = data[2] - '0'; + switch (data[1]){ + case ('+'): + result = a + b; + return result; + case ('-'): + result = a - b; + return result; + case ('*'): + result = a * b; + return result; + case ('/'): + result = a / b; + return result; + } + return 0; +} \ No newline at end of file