Advertisement
Sitisom

L2

Apr 5th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 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, l = st.length(); i < l && s != 3; i++) {
  13.         c = st[i];
  14.         switch (s) {
  15.         case 0:
  16.             if (c == 'A' || c == 'C')
  17.                 s = 0;
  18.             else if (c == 'B')
  19.                 s = 1;
  20.             else
  21.                 s = 3;
  22.             break;
  23.         case 1:
  24.             if (c == 'C' || c=='A')
  25.                 s = 2;
  26.             else
  27.                 s = 3;
  28.             break;
  29.         case 2:
  30.             if (c == 'A' || c == 'B' || c == 'C')
  31.                 s = 3;
  32.             break;
  33.         }
  34.     }
  35.     if (s == 2) cout << "Yes";
  36.     else if (s == 3) cout << "No";
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement