#include <iostream>
#include <cstdint>

// 1. Declare enum class PinState with underlying type uint8_t
// We use 'enum class' for scoping and 'uint8_t' to specify the memory size.
enum class PinState : uint8_t {
    Low,
    High
};

// 2. Implement: const char* toString(PinState s)
// This function acts as a lookup to turn our typed enum into a readable string.
const char* toString(PinState s) {
    switch (s) {
        case PinState::Low:
            return "LOW";
        case PinState::High:
            return "HIGH";
        default:
            return "UNKNOWN"; // Fallback, though not needed per your specs
    }
}

int main() {
    int x;
    if (!(std::cin >> x)) return 0;

    // x is guaranteed to be 0 or 1 per requirements
    // Mapping: 0 -> Low, 1 -> High
    PinState s = (x == 0) ? PinState::Low : PinState::High;
    
    // Output the string representation
    std::cout << toString(s);
    
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

0

Expected Output

LOW