⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enum.cpp

📁 Since the field of object oriented programming is probably new to you, you will find that there is a
💻 CPP
字号:
                                  // Chapter 2 - Program 1 - ENUM.CPP
#include <iostream.h>

enum game_result {WIN, LOSE, TIE, CANCEL};

int main()
{
game_result result;
enum game_result omit = CANCEL;
int count;

   for (count = WIN ; count <= CANCEL ; count++) 
   {
      result = (game_result)count;
      if (result == omit)
      { 
         cout << "The game was cancelled\n";
      }
      else 
      {
         cout << "The game was played ";
         if (result == WIN)
            cout << "and we won!";
         if (result == LOSE)
            cout << "and we lost.";
         cout << "\n";
      }
   }

   return 0;
}




// Result of execution
//
// The game was played and we won!
// The game was played and we lost.
// The game was played
// The game was cancelled

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -