diff --git a/more/0344.cpp b/more/0344.cpp new file mode 100644 index 0000000..43d15da --- /dev/null +++ b/more/0344.cpp @@ -0,0 +1,24 @@ +#include + +class Solution { +public: + static void reverseString(std::vector& s) { + char tmp; + for (int i = 0, j = s.size() - 1; i < j; ++i, --j) { + tmp = s[i]; + s[i] = s[j]; + s[j] = tmp; + } + } +}; + +int main() { + const char str[] = "hello"; + std::vector args; + args.reserve(sizeof str); + for (auto i : str) + if (i) + args.push_back(i); + Solution::reverseString(args); + return 0; +} \ No newline at end of file diff --git a/more/CMakeLists.txt b/more/CMakeLists.txt index c2102a4..1241580 100644 --- a/more/CMakeLists.txt +++ b/more/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(more) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(more 0100.cpp) +ADD_EXECUTABLE(more 0344.cpp)