Advertisement
Guest User

Untitled

a guest
May 21st, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include "pch.h"
  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. char x;
  10. int q = 0;
  11. while (in >> x && q != 8)
  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 == 'A')
  28. q = 3;
  29. else
  30. if (x == 'B' || x == 'C')
  31. q = 4;
  32. else
  33. if (x == 'D')
  34. q = 5;
  35. else q = 8;
  36. break;
  37. case 3:
  38. if (x == 'B')
  39. q = 5;
  40. else q = 8;
  41. break;
  42. case 4:
  43. if (x == 'E')
  44. q = 5;
  45. else q = 8;
  46. break;
  47. case 5:
  48. if (x == 'A')
  49. q = 6;
  50. else q = 8;
  51. break;
  52. case 6:
  53. if (x == 'E')
  54. q = 7;
  55. else
  56. if (x == 'A')
  57. q = 3;
  58. else
  59. if (x == 'B' || x == 'C')
  60. q = 4;
  61. else
  62. if (x == 'D')
  63. q = 5;
  64. else q = 8;
  65. break;
  66. case 7:
  67. if (x)
  68. q = 8;
  69. break;
  70. }
  71. out << "\t" << q << endl;
  72. }
  73. if (q == 7)
  74. cout << "Yes";
  75. else
  76. cout << "No";
  77. in.close();
  78. out.close();
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement