Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream in("input.txt");
- ofstream out("out.txt");
- char s, y;
- out << "New string: " << endl;
- int q = 1, count = 1;
- bool p1 = false;
- bool p2 = false;
- bool p3 = false;
- while ((in >> s) && (q != 5))
- {
- switch (q)
- {
- case 1:
- if (s == 'a') {
- out << 'm';
- q = 2;
- y = 'm';
- }
- else if (s == 'b') {
- out << 'p';
- q = 2;
- y = 'p';
- }
- else q = 5;
- break;
- case 2:
- if (s == 'a') {
- out << 'm';
- q = 3;
- y = 'm';
- }
- else if (s == 'b') {
- out << 's';
- q = 3;
- y = 's';
- }
- else q = 5;
- break;
- case 3:
- if (s == 'a') {
- out << 'v';
- q = 4;
- y = 'v';
- }
- else if (s == 'b') {
- out << 'r';
- q = 1;
- y = 'r';
- }
- else q = 5;
- break;
- case 4:
- if (s == 'a') {
- out << 'p';
- q = 4;
- y = 'p';
- }
- else if (s == 'b') {
- out << 's';
- q = 3;
- y = 's';
- }
- else q = 5;
- break;
- }
- count++;
- if (count == 10 && y == 'm')
- p1 = true;
- if (count == 20 && y == 'm')
- p2 = true;
- if (count == 30 && y == 'm')
- p3 = true;
- }
- if (p1) cout << "y1 at 10th" << endl;
- else cout << "not y1 at 10th" << endl;
- if (p2) cout << "y1 at 20th" << endl;
- else cout << "not y1 at 20th" << endl;
- if (p3) cout << "y1 at 30th" << endl;
- else cout << "not y1 at 30th" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement