首页 编程C/C++使用枚举型常量与整型常量

使用枚举型常量与整型常量

#include <iostream>
void main()
{
 typedef unsigned short int USI;
 const USI Sunday = 0;
 const USI Monday = 1;
 const USI Tuesday = 2;
 const USI Wednesday = 3;
 const USI Thursday = 4;
 const USI Friday = 5;
 const USI Saturday = 6;
 USI Today = Sunday;
 if (Today == Sunday || Today == Saturday)
  std::cout << “nGotta Weekends!n”;
 else
  std::cout << “nGo to work!n”;
}

#include <iostream>
int main()
{
 enum Days {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday};
 Days today;
 today = Tuesday;
 if (today == Sunday || today == Saturday)
 {
  std::cout << “nGotta’ Love the Weekends!n”;
 }
 else
  std::cout << “nBack to work!n”;
 return 0;
}

上一篇:
下一篇: