Aleksandr_Grigoryev

Мура 3

Feb 13th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int m[5][2] = { { 1,4 },{ 1,2 },{ 3,2 },{ 3,4 },{ 4,4 } };
  6.     char c[50];
  7.     for (int i = 0; i<5; i++)
  8.     {
  9.         cin >> c;
  10.         int k = strlen(c);
  11.         int q = 0;
  12.         for (int j = 0; (j<k) && (q != 4); j++)
  13.         {
  14.             int x = c[j] - '0';
  15.             cout << x << endl;
  16.             q = m[q][x];
  17.             cout << q << endl;
  18.         }
  19.         if (q == 3)
  20.             cout << "принадлежит" << endl;
  21.         else cout << "error";
  22.     }
  23.     system("pause");
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment