Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PAVEL_MELL.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
- //
- #include <iostream>
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- int mark = 0, i;
- bool EO_line = false;
- int difference = 0;
- int mas[4][5] = {
- // 0 1 a b \0
- { 0, 1, 2, 3, -2},//0
- { -1, 1, 2, -1, -2 },//1
- { -1, -1, 2, 3, -2 }, //2
- { -1, -1, -1, 3, -2 } };//3
- string sequence;
- cin >> sequence;
- for (i = 0; i <= sequence.length(); i++) {
- switch (sequence[i]) {
- case '0': mark = mas[mark][0];
- break;
- case '1': mark = mas[mark][1];
- break;
- case 'a': {
- mark = mas[mark][2];
- difference++;
- break;
- }
- case 'b': {
- mark = mas[mark][3];
- difference--;
- break;
- }
- case '\0': mark = mas[mark][4];
- break;
- default: mark = -1;
- break;
- }
- if (mark == -2) {
- EO_line = true;
- break;
- }
- if (mark == -1) {
- break;
- }
- }
- if (difference > 0)
- cout<< endl << "No, error in markition " << i + 1 << " = " << sequence[i] << endl;
- else if (difference < 0)
- cout << endl<< "No, error in markition " << i + 1 + (difference) << " = " << sequence[i + difference] << endl;
- else if (not EO_line) {
- cout << endl << "No, error in markition " << i + 1 << " = " << sequence[i] << endl;
- }
- else {
- cout << "Yes" << endl;
- }
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement