diff options
Diffstat (limited to 'tests/ii/strings/reference.cc')
| -rw-r--r-- | tests/ii/strings/reference.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ii/strings/reference.cc b/tests/ii/strings/reference.cc new file mode 100644 index 0000000..54d6efc --- /dev/null +++ b/tests/ii/strings/reference.cc @@ -0,0 +1,20 @@ +#include <algorithm> +#include <cctype> +#include <iostream> +#include <string> +int main() { + int count; + if (!(std::cin >> count)) return 1; + for (int i = 0; i < count; ++i) { + int empty, start, width; + std::string text; + if (!(std::cin >> empty >> text >> start >> width)) return 1; + if (empty) text.clear(); + auto lower = text, upper = text; + for (auto &c : lower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); + for (auto &c : upper) c = static_cast<char>(std::toupper(static_cast<unsigned char>(c))); + auto mid = text.substr(static_cast<std::size_t>(start - 1), static_cast<std::size_t>(width)); + auto right = text.substr(text.size() - static_cast<std::size_t>(width)); + std::cout << text.size() << ':' << mid << ':' << right << ":TRUE:" << lower << ':' << upper << '\n'; + } +} |
