Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- char c;
- string st;
- getline(cin, st);
- int s = 0;
- for (int i = 0, l = st.length(); i < l && s != 4; i++) {
- c = st[i];
- switch (s) {
- case 0:
- if (c == 'A' || c == 'B')
- s = 1;
- else
- s = 4;
- break;
- case 1:
- if (c == 'C')
- s = 2;
- else
- s = 4;
- break;
- case 2:
- if (c == 'A' || c == 'B' || c == 'E')
- s = 2;
- else if (c == 'D')
- s = 3;
- else
- s = 4;
- break;
- case 3:
- if (c == 'D')
- s = 3;
- else
- s = 4;
- break;
- }
- }
- if (s == 3) cout << "Yes";
- else if (s == 4) cout << "No";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement