Advertisement
Sitisom

L3

Apr 3rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char c;
  9.     string st;
  10.     getline(cin, st);
  11.     int s = 0;
  12.     for (int i = 0; i < st.length() && s != 4; i++) {
  13.         char c = st[i];
  14.         switch (s) {
  15.         case 0:
  16.             if (c == 'A')
  17.                 s = 1;
  18.             else
  19.                 s = 4;
  20.             break;
  21.         case 1:
  22.             if (c == 'B')
  23.                 s = 2;
  24.             else
  25.                 s = 4;
  26.             break;
  27.         case 2:
  28.             if (c == 'A' || c == 'C')
  29.                 s = 2;
  30.             else if (c == 'B')
  31.                 s = 3;
  32.             else
  33.                 s = 4;
  34.             break;
  35.         case 3:
  36.             if (c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E')
  37.                 s = 4;
  38.             break;
  39.         }
  40.     }
  41.     if (s == 3) cout << "Yes";
  42.     else if (s == 4) cout << "No";
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement