add: 0344
This commit is contained in:
parent
2d3e268d3e
commit
491c957eee
|
|
@ -0,0 +1,24 @@
|
|||
#include <vector>
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
static void reverseString(std::vector<char>& 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<char> args;
|
||||
args.reserve(sizeof str);
|
||||
for (auto i : str)
|
||||
if (i)
|
||||
args.push_back(i);
|
||||
Solution::reverseString(args);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3,4 +3,4 @@ PROJECT(more)
|
|||
|
||||
SET(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
ADD_EXECUTABLE(more 0100.cpp)
|
||||
ADD_EXECUTABLE(more 0344.cpp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue