#include #include #include #include #include using namespace std; int main() { const char sun {1 << 0}; //00000001 const char mon {1 << 1}; //00000010 const char tue {1 << 2}; //00000100 const char wed {1 << 3}; //00001000 const char thu {1 << 4}; //00010000 const char fri {1 << 5}; //00100000 const char sat {1 << 6}; //01000000 struct restaurant { string name; char days; }; const restaurant a[] { {"Katz's Delicatessen", sun | mon | tue}, {"Tavern on the Green", sat | sun}, {"Wo Hop", sun | mon | tue | wed | thu | fri | sat}, {"Luchow's", mon | tue | wed}, {"Delmonico's", thu | fri | sun}, {"Never Open Diner", } }; const size_t n {size(a)}; for (int i {0}; i < n; ++i) { int open_days_count {0}; for (int bit {0}; bit < 7; ++bit) { if ((a[i].days >> bit) & 0x1) { ++open_days_count; } } cout << a[i].name << " " << open_days_count << "\n"; } return EXIT_SUCCESS; }