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