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

📄 猜拳.cpp

📁 有关猜拳的一个代码
💻 CPP
字号:
#include<iostream>
using namespace std;
#define player1 0;
#define palyer2 1;
#define tie 2;
void main()//下面怎样安排誰赢取决怎样定义石头,剪刀和布的值。然后把每种可能赢的情况列出就可以得到结果

{
int choice1,choice2,winner;
cout<<"choose rock(0),cloth(1),or scissors(2):"<<endl;
cout<<"player#1:";
cin<<choice1;
cout<<"player#2:";
cin<<choice2;
switch (choice2-choice1)
{
	case 0;
		winner=tie;
		cout<<"\tyou tied."<<endl;
		break;
case-1:
case2:
	winner=player1;
	cout<<"\tplayer1 is the winner."<<endl;
	break;
	case-2; 
		case 1;
			winner=player2;
			cout<<\tplayer2 is the winner."<<endl;
}
}

⌨️ 快捷键说明

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