Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int c;
- void A();
- void B();
- void C();
- void gc()
- {
- cin >> c;
- }
- void S()
- {
- C();
- gc();
- if (!(c == '0' || c == '1')) {
- throw 1;
- }
- }
- void A()
- {
- if (c != '0' && c != '1') {
- gc();
- A();
- if (!(c == '0' || c == '1')) {
- throw 1;
- }
- }
- }
- void B()
- {
- if (c != '1') {
- A();
- gc();
- if (c != '1') {
- throw 1;
- }
- }
- }
- void C()
- {
- B();
- gc();
- if (c != '0' && c != '1') {
- throw 1;
- }
- }
- int main(void)
- {
- try {
- gc();
- S();
- } catch (int) {
- cout << "wrong" << endl;
- return 0;
- }
- cout << "OK" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement