mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 18:23:07 +02:00
- 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
30 lines
771 B
C++
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
|