main(){
enum weekday
{ sun,mon,tue,wed,thu,fri,sat } a,b,c;
a = sun;
b = mon;
c = tue;
printf( " %d,%d,%d " ,a,b,c);
}
main(){
enum body
{ a,b,c,d } month[ 31 ],j;
int i;
j = a;
for (i = 1 ;i <= 30 ;i ++ ){
month[i] = j;
j ++ ;
if (j > d) j = a;
}
for (i = 1 ;i <= 30 ;i ++ ){
switch (month[i])
{
case a:printf( " %2d %c\t " ,i, ' a ' ); break ;
case b:printf( " %2d %c\t " ,i, ' b ' ); break ;
case c:printf( " %2d %c\t " ,i, ' c ' ); break ;
case d:printf( " %2d %c\t " ,i, ' d ' ); break ;
default : break ;
}
}
printf( " \n " );
}
#include<stdio.h>
enum
{
BELL = '/a',
BACKSPACE = '/b',
HTAB = '/t',
RETURN = '/r',
NEWLINE = '/n',
VTAB = '/v',
SPACE = ' '
};
enum BOOLEAN { FALSE = 0, TRUE } match_flag;
void main()
{
int index = 0;
int count_of_letter = 0;
int count_of_space = 0;
char str[] = "I'm Ely efod";
match_flag = FALSE;
for(; str[index] != '/0'; index++)
if( SPACE != str[index] )
count_of_letter++;
else
{
match_flag = (enum BOOLEAN) 1;
count_of_space++;
}
printf("%s %d times %c", match_flag ? "match" : "not match", count_of_space, NEWLINE);
printf("count of letters: %d %c%c", count_of_letter, NEWLINE, RETURN);
}
输出:
match 2 times
count of letters: 10
Press any key to continue