C++语言程序设计案例教程,郑莉编的书

源代码在线查看: 2_40.cpp

软件大小: 202 K
上传用户: WJQ198926
关键词: 语言程序设计 案例 教程
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include 
				using namespace std;
				enum Choice {ROCK, CLOTH, SCISS};	//声明枚举类型Choice
				enum Winner {Play1, Play2, Tie}; 		//声明枚举类型Winner
				int main()
				{	int n;	
				   Choice cho1, cho2;		
				   Winner winner;
					cout 					cout > n;	cho1 = Choice(n);
					cout > n;	cho2 = Choice(n);
					if (cho1 == cho2) winner = Tie;
					else if (cho1 == ROCK)
						if (cho2 == CLOTH) 	winner = Play2;
						else 	winner = Play1;
					else if (cho1 == CLOTH)
						if (cho2 == SCISS) 	winner = Play2;
						else 	winner = Play1;
					else 
						if (cho2 == ROCK) 	winner = Play2;
						else 	winner = Play1;
					if (winner == Tie) 		cout 					else if (winner == Play1) 	cout 					else 	cout 					return 0;
				}
							

相关资源