Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- int q = 0;
- char x;
- while (in >> x && q != 5)
- {
- out << x;
- switch (q)
- {
- case 0:
- if (x == 'D')
- q = 1;
- else q = 8;
- break;
- case 1:
- if (x == 'B')
- q = 2;
- else q = 8;
- break;
- case 2:
- if (x == 'C' || x == 'B')
- q = 3;
- else if (x == 'A')
- q = 4;
- else if (x == 'D')
- q = 5;
- else q = 8;
- break;
- case 3:
- if (x == 'E')
- q = 5;
- else q = 8;
- break;
- case 4:
- if (x == 'B')
- q = 5;
- else q = 8;
- break;
- case 5:
- if (x == 'A')
- q = 6;
- else q = 8;
- break;
- case 6:
- if (x == 'E')
- q = 7;
- else q = 2;
- break;
- case 7:
- if (x)
- q = 8;
- break;
- }
- out << "\t" << q << endl;
- }
- if (q == 8)
- out << "Yes";
- else out << "No";
- in.close();
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement