[C]enum类型

2021-04-22 18:29

阅读:356

标签:include   return   div   seve   std   ase   color   ==   print   

 

#include 

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 

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;
}

 

[C]enum类型

标签:include   return   div   seve   std   ase   color   ==   print   

原文地址:https://www.cnblogs.com/profesor/p/13276091.html


评论


亲,登录后才可以留言!