Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int c;
  5. void A();
  6. void B();
  7. void C();
  8.  
  9. void gc()
  10. {
  11. cin >> c;
  12. }
  13. void S()
  14. {
  15. C();
  16. gc();
  17. if (!(c == '0' || c == '1')) {
  18. throw 1;
  19. }
  20. }
  21. void A()
  22. {
  23. if (c != '0' && c != '1') {
  24. gc();
  25. A();
  26.  
  27. if (!(c == '0' || c == '1')) {
  28. throw 1;
  29. }
  30. }
  31. }
  32. void B()
  33. {
  34. if (c != '1') {
  35. A();
  36. gc();
  37. if (c != '1') {
  38. throw 1;
  39. }
  40. }
  41. }
  42. void C()
  43. {
  44. B();
  45. gc();
  46. if (c != '0' && c != '1') {
  47. throw 1;
  48. }
  49. }
  50. int main(void)
  51. {
  52. try {
  53. gc();
  54. S();
  55. } catch (int) {
  56. cout << "wrong" << endl;
  57. return 0;
  58. }
  59. cout << "OK" << endl;
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement