Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. int a, b, Q;
  10. std::string text;
  11. getline(std::cin, text);
  12. std::cin >> Q;
  13. bool* invert = new bool[text.length()];
  14. for (int i = 0; i < text.length(); i++) {
  15. invert[i] = true;
  16. }
  17.  
  18. for (int i = 0; i < Q; i++) {
  19. std::cin >> a >> b;
  20. for (int j = a - 1; j < b; j++) {
  21. invert[j] = !invert[j];
  22.  
  23. }
  24. }
  25.  
  26. for (int i = 0; i < text.length();i++) {
  27. if (!invert[i]) {
  28. if (isupper(text[i])) {
  29. text[i] = tolower(text[i]);
  30. }
  31. else {
  32. text[i] = toupper(text[i]);
  33. }
  34. }
  35.  
  36. }
  37.  
  38. std::cout << text;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement