Advertisement
Hamoudi30

Untitled

May 14th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 1e6+7;
  4. int vis[N];
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(nullptr);
  8.     cout.tie(nullptr);
  9. //    freopen("/home/hamoudi/Coding/run.in", "r", stdin);
  10.     int tt = 1;
  11. //    cin >> tt;
  12.     while (tt--) {
  13.         int n;
  14.         cin >> n;
  15.         string input_text = "";
  16.         string str;
  17.         for (int i = 0; i < n; ++i) {
  18.             cin >> str;
  19.             if (i > 0) input_text += " ";
  20.             input_text += str;
  21.         }
  22.         int m;
  23.         cin >> m;
  24. //        it will be true because we start with lowercase
  25.         bool lower = true;
  26.         string operation;
  27.         string final_result = "";
  28.         while (m--) {
  29.             cin >> operation;
  30.             if (operation == "CapsLock") {
  31.                 lower = !lower;
  32. //                just flip lower to upper and vice versa
  33.             } else if (operation == "Backspace") {
  34. //                first check if input text is empty or not
  35.                 if (not final_result.empty())
  36.                     final_result.pop_back(); // remove the last if it's not empty
  37.             } else if (operation == "Space") {
  38. //                    add space to final string
  39.                     final_result += " ";
  40.             } else {
  41. //                in this case we must have input character to add
  42. //                so i have to check Capslock
  43.                 if (lower) {
  44.                     final_result += tolower(operation[0]);
  45.                 } else {
  46.                     final_result += toupper(operation[0]);
  47.                 }
  48.             }
  49.         }
  50.         if (final_result == input_text)
  51.             cout << "Correct";
  52.         else
  53.             cout << "Incorrect";
  54.         cout << endl;
  55.     }
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement