#include <iostream> using namespace std; // Define LED class here // <write your code> class LED { int pin; int state; public: explicit LED(int pin) noexcept : state(0), pin(pin) {}; void on() noexcept { state = 1; } void off() noexcept { state = 0; } void toggle() noexcept { state = !state; } int status() const noexcept{ return state; } }; int main() { int pin, initialState, toggleCount; cin >> pin >> initialState >> toggleCount; LED led(pin); if (initialState == 1) led.on(); else led.off(); for (int i = 0; i < toggleCount; i++) { led.toggle(); } cout << led.status(); return 0; }
Test Cases
Test Results
Input
5 1 3
Expected Output
0