Advertisement
mfgnik

Untitled

Mar 29th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. #include <codecvt>
  4. #include <locale>
  5. #include <algorithm>
  6. #include <string>
  7. #include <vector>
  8.  
  9. std::string convertString(const std::string& line) {
  10.     std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
  11.     std::wstring converted_line = converter.from_bytes(line);
  12.     std::reverse(converted_line.begin(), converted_line.end());
  13.     using convert_type = std::codecvt_utf8<wchar_t>;
  14.     std::wstring_convert<convert_type, wchar_t> converter_second;
  15.     return converter.to_bytes(converted_line);
  16. }
  17.  
  18. int main() {
  19.     std::string line;
  20.     std::vector<std::string> lines;
  21.     while (std::cin >> line) {
  22.         lines.push_back(line);
  23.     }
  24.     std::reverse(lines.begin(), lines.end());
  25.     setlocale(LC_ALL, "");
  26.     for (const auto& line: lines) {
  27.         std::cout << convertString(line) << " ";
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement