Advertisement
Guest User

Untitled

a guest
May 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. int main()
  6. {
  7. ifstream in("input.txt");
  8. ofstream out("output.txt");
  9. int q = 0;
  10. char x;
  11. while (in >> x && q != 5)
  12. {
  13. out << x;
  14. switch (q)
  15. {
  16. case 0:
  17. if (x == 'D')
  18. q = 1;
  19. else q = 8;
  20. break;
  21. case 1:
  22. if (x == 'B')
  23. q = 2;
  24. else q = 8;
  25. break;
  26. case 2:
  27. if (x == 'C' || x == 'B')
  28. q = 3;
  29. else if (x == 'A')
  30. q = 4;
  31. else if (x == 'D')
  32. q = 5;
  33. else q = 8;
  34. break;
  35. case 3:
  36. if (x == 'E')
  37. q = 5;
  38. else q = 8;
  39. break;
  40. case 4:
  41. if (x == 'B')
  42. q = 5;
  43. else q = 8;
  44. break;
  45. case 5:
  46. if (x == 'A')
  47. q = 6;
  48. else q = 8;
  49. break;
  50. case 6:
  51. if (x == 'E')
  52. q = 7;
  53. else q = 2;
  54. break;
  55. case 7:
  56. if (x)
  57. q = 8;
  58. break;
  59. }
  60. out << "\t" << q << endl;
  61. }
  62. if (q == 8)
  63. out << "Yes";
  64. else out << "No";
  65. in.close();
  66. out.close();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement