#include <stdio.h>
#include <stdlib.h>
typedef enum {
Sunday = 0x01,
Monday = 0x02,
Tuesday = 0x04,
Wednesday = 0x08,
Thursday = 0x10,
Friday = 0x20,
Saturday = 0x40
} DaysSet;
char* days_str[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
DaysSet week_end = Sunday | Saturday;
int main() {
int order;
printf("Please enter the day of the week (0 to 6)\n");
scanf("%d", &order);
if (((1 << order) & week_end) > 0 ) {
printf("%s is weekend\n", days_str[order]);
} else {
printf("%s is week\n", days_str[order]);
}
return EXIT_SUCCESS;
}
沒有留言:
張貼留言