pthread.h
c\ntypedef struct\n{\n        int n;\n        int printed;\n        int zeroflag, numflag;\n        pthread_mutex_t mtx;\n        pthread_cond_t cnd;\n} ZeroEve
```c\ntypedef struct\n{\n        int n;\n        int printed;\n        int zeroflag, numflag;\n        pthread_mutex_t mtx;\n        pthread_cond_t cnd;\n} ZeroEvenOdd;\n\nZeroEvenOdd *\nzeroEvenOddCreate(int n)\n{\n        ZeroEvenOdd *z;\n        z = calloc(1, sizeof(*z));\n        z->n = n;\n        z->printed = 1;\n        z->zeroflag = 1;\n        z->numflag = 1;\n        pthread_mutex_init(&z->mtx, NULL);\n        pthread_cond_init(&z->cnd, NULL);\n        return z;\n}\n\nvoid\nzero(ZeroEvenOdd *z)\n{\n        pthread_mutex_lock(&z->mtx);\nmain_loop:\n        while (z->printed-1 != z->n) {\n                while (!z->zeroflag) {\n                        pthread_cond_wait(&z->cnd, &z->mtx);\n                        goto main_loop;\n                }\n                z->zeroflag = 0;\n                printNumber(0);\n                pthread_cond_broadcast(&z->cnd);\n        }\n        pthread_mutex_unlock(&z->mtx);\n}\n\nvoid\neven(ZeroEvenOdd *z)\n{\n        pthread_mutex_lock(&z->mtx);\nmain_loop:\n        while (z->printed-1 != z->n) {\n                while (z->zeroflag || z->numflag == 1) {\n                        pthread_cond_wait(&z->cnd, &z->mtx);\n                        goto main_loop;\n                }\n                z->numflag = 1;\n                z->zeroflag = 1;\n                printNumber(z->printed++);\n                pthread_cond_broadcast(&z->cnd);\n        }\n        pthread_mutex_unlock(&z->mtx);\n}\n\nvoid\nodd(ZeroEvenOdd *z)\n{\n        pthread_mutex_lock(&z->mtx);\nmain_loop:\n        while (z->printed-1 != z->n) {\n                while (z->zeroflag || z->numflag == 2) {\n                        pthread_cond_wait(&z->cnd, &z->mtx);\n                        goto main_loop;\n                }\n                z->numflag = 2;\n                z->zeroflag = 1;\n                printNumber(z->printed++);\n                pthread_cond_broadcast(&z->cnd);\n        }\n        pthread_mutex_unlock(&z->mtx);\n}\n\nvoid\nzeroEvenOddFree(ZeroEvenOdd *z)\n{\n        free(z);\n}\n```
['C']