类与对象2

#include<iostream>
using namespace std;
enum GameResult {WIN,LOSE,TIE,CANCEL};
int main()
{
GameResult result;
enum GameResult omit=CANCEL;
for (int count=WIN;count <=CANCEL;count++){
result=GameResult(count);
if(result==omit)
cout<<"The game was cancelled"<<endl;
else{
cout<<"The game was played";
if(result==WIN)
cout<<"and we won!";
if(result==LOSE)
cout<<"and we lost.";
cout<<endl;
}
}
return 0;
}

posted @   不会JAVA的小袁  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示