猜拳.cpp

来自「有关猜拳的一个代码」· C++ 代码 · 共 31 行

CPP
31
字号
#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 + =
减小字号Ctrl + -
显示快捷键?