Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int a, b, Q;
- std::string text;
- getline(std::cin, text);
- std::cin >> Q;
- bool* invert = new bool[text.length()];
- for (int i = 0; i < text.length(); i++) {
- invert[i] = true;
- }
- for (int i = 0; i < Q; i++) {
- std::cin >> a >> b;
- for (int j = a - 1; j < b; j++) {
- invert[j] = !invert[j];
- }
- }
- for (int i = 0; i < text.length();i++) {
- if (!invert[i]) {
- if (isupper(text[i])) {
- text[i] = tolower(text[i]);
- }
- else {
- text[i] = toupper(text[i]);
- }
- }
- }
- std::cout << text;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement