#include <iostream>
#include <cstdint>
using namespace std;

enum class ErrorCode {
    None = 0,
    Timeout = 1,
    Overflow = 2,
    Invalid = 3
};

const char* toString(ErrorCode e){
    switch(e){
        case ErrorCode::None :
            return "None";
        case ErrorCode::Timeout:
            return "Timeout";
        case ErrorCode::Overflow:
            return "Overflow";
        case ErrorCode::Invalid:
            return "Invalid";
        default:
            break;
    }

}

int main() {
    int x;
    cin >> x;

    // Input value is guaranteed to be in the range 0&#8211;3
    ErrorCode e = static_cast<ErrorCode>(x);

    cout << toString(e);
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

0

Expected Output

None