Advertisement
Guest User

вариант 4

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