This program reverses a given string.
#include <iostream>
#include <string>
int main() {
std::string str;
std::cout << "Enter a string: ";
std::cin >> str;
std::string reversedStr = std::string(str.rbegin(), str.rend());
std::cout << "Reversed string: " << reversedStr << std::endl;
return 0;
}
No comments:
Post a Comment