Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- using std::endl;
- using std::cin;
- void S();
- void A();
- void B();
- void S()
- {
- char c;
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c == '1') {
- A();
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c != '0') {
- throw c;
- }
- } else {
- throw c;
- }
- }
- void A()
- {
- char c;
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c == '1') {
- A();
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c != '0') {
- throw c;
- }
- } else if (c == '0') {
- B();
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c != '1') {
- throw c;
- }
- } else {
- throw c;
- }
- }
- void B()
- {
- char c;
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c == '0') {
- B();
- if (!(cin >> c)) {
- throw "fail";
- }
- if (c != '1') {
- throw c;
- }
- } else {
- cin.putback(c);
- }
- }
- int main()
- {
- while (true) {
- try {
- S();
- } catch (char c) {
- if (isspace(c)) {
- cout << "WIN" << endl;
- try {
- S();
- } catch (...) {
- throw;
- }
- } else {
- throw;
- }
- } catch (...) {
- cout << "FAIL" << endl;
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement