Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 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')
  25. q = 1;
  26. else
  27. q = 5;
  28. break;
  29. case 1:
  30. if (x == 'B' || x == 'D' || x == 'A')
  31. q = 2;
  32. else
  33. q = 5;
  34. break;
  35. case 2:
  36. if (x == 'A' || x == 'C')
  37. q = 3;
  38. else
  39. q = 5;
  40. break;
  41. case 3:
  42. if (x == 'E')
  43. q = 4;
  44. else
  45. q = 5;
  46. break;
  47. default: q = 5; break;
  48. }
  49. out << setw(2) << q << endl;
  50. }
  51. out << endl;
  52. if (q == 4)
  53. out << "OK" << endl;
  54. else
  55. out << "NO" << endl;
  56. in.close();
  57. out.close();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement