C++| zero semaphore
\n#include<semaphore.h>\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    sem_t e;\n    sem_t o;\n    sem_t z;\n    int i = 1;\n\npublic:\n    ZeroEvenOdd(int n) 
```\n#include<semaphore.h>\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    sem_t e;\n    sem_t o;\n    sem_t z;\n    int i = 1;\n\npublic:\n    ZeroEvenOdd(int n) {\n        this->n = n;\n        i = 1;\n        sem_init(&z,0,0);\n        sem_init(&o,0,0);\n        sem_init(&e,0,0);\n        \n    }\n\n    // printNumber(x) outputs "x", where x is an integer.\n    void zero(function<void(int)> printNumber) {\n        \n        while(i <= n)\n        {\n            if(i <= n)\n                printNumber(0);\n            if(i % 2 == 1)\n                sem_post(&o);\n            else\n                sem_post(&e);\n            sem_wait(&z);\n        }\n        sem_post(&o);\n        sem_post(&e);\n        \n    }\n\n    void even(function<void(int)> printNumber) {\n        \n        while(i <= n)\n        {\n            sem_wait(&e);\n            if(i <= n)\n                printNumber(i);\n            i++;\n            sem_post(&z);\n        }\n        sem_post(&z);\n        \n    }\n\n    void odd(function<void(int)> printNumber) {\n        while(i <= n)\n        {\n            sem_wait(&o);\n            if(i <= n)\n                printNumber(i);\n            i++;\n            sem_post(&z);\n        }\n        sem_post(&z);\n    }\n};\n```
['C']