2026-04-12 20:45:24 +02:00
|
|
|
#include "reverseString.h"
|
2026-02-20 00:37:32 +01:00
|
|
|
#include <algorithm>
|
2025-11-30 13:42:16 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2026-04-12 20:45:24 +02:00
|
|
|
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
|
2026-02-20 00:37:32 +01:00
|
|
|
int main() {
|
|
|
|
|
std::string userString;
|
|
|
|
|
getline(std::cin, userString);
|
2026-04-12 20:45:24 +02:00
|
|
|
std::string tempString = reverseStringManual(userString);
|
|
|
|
|
std::string stdReversed = userString;
|
|
|
|
|
reverse(stdReversed.begin(), stdReversed.end());
|
|
|
|
|
bool correct = tempString == stdReversed;
|
2026-02-20 00:37:32 +01:00
|
|
|
std::cout << correct << std::endl;
|
|
|
|
|
std::cout << tempString << std::endl;
|
|
|
|
|
return 0;
|
2025-11-30 13:42:16 +01:00
|
|
|
}
|
2026-04-12 20:45:24 +02:00
|
|
|
#endif
|