[C]enum类型

时间:2020-07-09 20:58:12   收藏:0   阅读:73

 

#include <stdio.h>

typedef enum {FALSE, TRUE} Boolean;

Boolean isEven(int i) {
    if ( i % 2 == 0 )
        return TRUE;
    else return FALSE;
}

int main() {
    int i = 10;
    printf("%d\n", isEven(i));
    return 0;
}

 

 

#include <stdio.h>

typedef enum {MON=1, TUE, WED, THU, FRI, SAT, SUN} days_of_week;

int main() {
    days_of_week d = SUN;
    switch (d) {
        case SUN: case SAT: printf("%s\n", "weekend"); break;
        default: printf("weekdays\n");
    }
    return 0;
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!