diff --git a/include/doctest.h b/include/doctest.h index d25f526..ed9d272 100644 --- a/include/doctest.h +++ b/include/doctest.h @@ -156,7 +156,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef") \ DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \ DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \ - \ + \ DOCTEST_GCC_SUPPRESS_WARNING_PUSH \ DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \ DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") \ @@ -167,7 +167,7 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") \ DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") \ DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") \ - \ + \ DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \ /* these 4 also disabled globally via cmake: */ \ DOCTEST_MSVC_SUPPRESS_WARNING(4514) /* unreferenced inline function has been removed */ \ diff --git a/src/Task1/task1.cpp b/src/Task1/task1.cpp index 9fb7ff4..b9c382c 100755 --- a/src/Task1/task1.cpp +++ b/src/Task1/task1.cpp @@ -1,26 +1,109 @@ #include using namespace std; -int solve(int n, vector arr){ - int answer=0; - // Start your code here +int solve(int n, vector arr) +{ + int answer = 0; + string temp, a, b, c; + // Started my code here + map mp; + for (int i = 0; i < n; i++) + { + string s; + for (int j = 0; j < arr[i].size(); j++) + { + if (arr[i][j] != ',') + { + s += arr[i][j]; + } + } + arr[i] = s; + } + for (int i = 0; i < n; i++) + { + string s = arr[i]; + stringstream ss; + ss << s; + ss >> s; + temp = s; + ss >> s; + a = s; + ss >> s; + b = s; + ss >> s; + c = s; - // End your code here + if (temp == "li") + { + stringstream str_to_num(b); + int add = 0; + str_to_num >> add; + mp[a] = add; + } + else if (temp == "add") + { + mp[a] = mp[b] + mp[c]; + } + else if (temp == "sub") + { + mp[a] = mp[b] - mp[c]; + } + else if (temp == "addi") + { + stringstream str_to_num(c); + int add = 0; + str_to_num >> add; + mp[a] = mp[b] + add; + } + else if (temp == "mul") + { + mp[a] = mp[b] * mp[c]; + } + else if (temp == "and") + { + mp[a] = mp[b] & mp[c]; + } + else if (temp == "or") + { + mp[a] = mp[b] | mp[c]; + } + else if (temp == "andi") + { + stringstream str_to_num(c); + int add = 0; + str_to_num >> add; + mp[a] = mp[b] & add; + } + else if (temp == "ori") + { + stringstream str_to_num(c); + int add = 0; + str_to_num >> add; + mp[a] = mp[b] | add; + } + else if (temp == "sw") + { + mp["answer"] = mp[a]; + answer = mp["answer"]; + } + } return answer; -} + } -int main(){ - // int n; - // cin>>n; - // cin.ignore(); - // vector arr(n); - // for(int i=0;i> n; +// cin.ignore(); +// vector arr(n); +// for (int i = 0; i < n; i++) +// { +// getline(cin, arr[i]); +// cout << arr[i] << endl; +// } +// cout << solve(n, arr); +// return 0; +// } -// ==> NOTE: Comment main function and uncomment below line to verify your code -// #include "../../include/test1_cases.h" \ No newline at end of file +// ==> NOTE: Comment main function and uncomment below line to verify your code +#include "../../include/test1_cases.h" \ No newline at end of file diff --git a/src/Task1/task1.exe b/src/Task1/task1.exe new file mode 100644 index 0000000..39ead53 Binary files /dev/null and b/src/Task1/task1.exe differ