testsAndMisc-archive/CPP/miscelanious/reverseString.cpp
Krzysztof kuhy Rudnicki 01091c09ce Add tests and fix pre-commit issues across all projects
- C/lichess_random_engine, vocabulary_curve, misc/split,
  1dvelocitysimulator, opening_learner: test suites added
- CPP/miscelanious: tests added
- TS/battery-status, champions_leauge_scores, two-inputs: tests added
- python_pkg/fm24_searcher, wake_alarm: new packages added
- Fix ruff/cppcheck/eslint/clang-format failures
- Update .gitignore for C/C++ build artifacts
2026-04-12 20:45:24 +02:00

30 lines
771 B
C++

#include "reverseString.h"
#include <algorithm>
#include <iostream>
#include <string>
std::string reverseStringManual(const std::string &s) {
std::string result = s;
int sLength = static_cast<int>(result.length());
for (int i = 0; i < sLength / 2; i++) {
char temp = result[sLength - 1 - i];
result[sLength - 1 - i] = result[i];
result[i] = temp;
}
return result;
}
#ifndef TESTING
int main() {
std::string userString;
getline(std::cin, userString);
std::string tempString = reverseStringManual(userString);
std::string stdReversed = userString;
reverse(stdReversed.begin(), stdReversed.end());
bool correct = tempString == stdReversed;
std::cout << correct << std::endl;
std::cout << tempString << std::endl;
return 0;
}
#endif