Language: C++


using namespace std;

bool checkMonth (int a)
{
        if ((a >= 1) && (a <= 12))
        {
                return true;
        }
        return false;
}

bool checkYear (int a)
{
        if ((a >= 0) && (a <= 99))
        {
                return true;
        }
        return false;
}


int main()
{
        string s;
        cin >> s;

        string first = s.substr(0,2);
        string second = s.substr(2,3);

        int a = atoi(first.c_str());
        int b = atoi(second.c_str());

        if ((checkMonth(a) && checkYear(b)) && (checkMonth(b) && checkYear(a)))
        {
                cout << "AMBIGUOUS" << endl;
        }

        else if ((checkMonth(a) && checkYear(b)))
                {
                        cout << "MMYY" << endl;
                }
        else if ((checkMonth(b) && checkYear(a)))
                {
                        cout << "YYMM" << endl;
                }
        else
        {
                cout << "NA" << endl;
        }


        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'string' was not declared in this scope
   25 |         string s;
      |         ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | 
a.cc:26:9: error: 'cin' was not declared in this scope
   26 |         cin >> s;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:26:16: error: 's' was not declared in this scope
   26 |         cin >> s;
      |                ^
a.cc:28:15: error: expected ';' before 'first'
   28 |         string first = s.substr(0,2);
      |               ^~~~~~
      |               ;
a.cc:29:15: error: expected ';' before 'second'
   29 |         string second = s.substr(2,3);
      |               ^~~~~~~
      |               ;
a.cc:31:22: error: 'first' was not declared in this scope
   31 |         int a = atoi(first.c_str());
      |                      ^~~~~
a.cc:31:17: error: 'atoi' was not declared in this scope
   31 |         int a = atoi(first.c_str());
      |                 ^~~~
a.cc:32:22: error: 'second' was not declared in this scope
   32 |         int b = atoi(second.c_str());
      |                      ^~~~~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << "AMBIGUOUS" << endl;
      |                 ^~~~
a.cc:36:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:40: error: 'endl' was not declared in this scope
   36 |                 cout << "AMBIGUOUS" << endl;
      |                                        ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | 
a.cc:41:25: error: 'cout' was not declared in this scope
   41 |                         cout << "MMYY" << endl;
      |                         ^~~~
a.cc:41:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:43: error: 'endl' was not declared in this scope
   41 |                         cout << "MMYY" << endl;
      |                                           ^~~~
a.cc:41:43: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:45:25: error: 'cout' was not declared in this scope
   45 |                         cout << "YYMM" << endl;
      |                         ^~~~
a.cc:45:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:45:43: error: 'endl' was not declared in this scope
   45 |                         cout << "YYMM" << endl;
      |                                           ^~~~
a.cc:45:43: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:49:17: error: 'cout' was not declared in this scope
   49 |                 cout << "NA" << endl;
      |                 ^~~~
a.cc:49:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:49:33: error: 'endl' was not declared in this scope
   49 |                 cout << "NA" << endl;
      |                                 ^~~~
a.cc:49:33: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'