#include <iostream> #include <cstdint> using namespace std; using ISRCallback = void (*)(int32_t); void onError(int32_t code) { cout << "ERROR " << code; } void onComplete(int32_t code) { cout << "COMPLETE " << code; } int main() { int32_t mode, eventCode; if (!(cin >> mode >> eventCode)) return 0; ISRCallback cb = nullptr; if(mode == 1){ cb = onError; } else if(mode == 2){ cb = onComplete; } if(cb){ cb(eventCode); } return 0; }
Test Cases
Test Results
Input
1 42
Expected Output
ERROR 42