#include <iostream> #include <cstdint> // Declare enum class PinState with underlying type uint8_t // Values: Low, High enum class PinState : uint8_t{ Low=0, High }; const char* toString(PinState s){ const char *value = "0"; if(s == PinState::Low){ value = "LOW"; } else if(s == PinState::High){ value = "HIGH"; } return value; } // Implement: const char* toString(PinState s) int main() { int x; std::cin >> x; // x is guaranteed to be 0 or 1 PinState s = (x == 0) ? PinState::Low : PinState::High; std::cout << toString(s); return 0; }
Test Cases
Test Results
Expected Output
LOW