//编程序模拟剪刀、石头和纸游戏。游戏规则为:剪刀剪纸,石头砸剪刀,纸包石头。玩游戏者从键盘上输入s(表示剪刀)
//或r(表示石头)或p(表示纸),要求两个游戏者交替输入,计算机给出输赢的信息。
#include"iostream.h"
void main()
{char first,second;
cout<<"请输入第一个剪刀石头布"<<'\n';
cin>>first;
cout<<"请输入第二个剪刀石头布"<<endl;
cin>>second;
if (first='s')
{switch(second)
{case 's':cout<<"平"<<'\n';break;
case 'r':cout<<"输"<<'\n';break;
case 'p':cout<<"赢"<<'\n';break;}}
else if (first='r')
{switch(second)
{case 's':cout<<"赢"<<'\n';break;
case 'r':cout<<"平"<<'\n';break;
case 'p':cout<<"输"<<'\n';break;}}
else if (first='p')
{switch(second)
{case 's':cout<<"输"<<'\n';break;
case 'r':cout<<"赢"<<'\n';break;
case 'p':cout<<"平"<<'\n';break;}}
else
cout<<"输入不正确"<<endl;
}
//或r(表示石头)或p(表示纸),要求两个游戏者交替输入,计算机给出输赢的信息。
#include"iostream.h"
void main()
{char first,second;
cout<<"请输入第一个剪刀石头布"<<'\n';
cin>>first;
cout<<"请输入第二个剪刀石头布"<<endl;
cin>>second;
if (first='s')
{switch(second)
{case 's':cout<<"平"<<'\n';break;
case 'r':cout<<"输"<<'\n';break;
case 'p':cout<<"赢"<<'\n';break;}}
else if (first='r')
{switch(second)
{case 's':cout<<"赢"<<'\n';break;
case 'r':cout<<"平"<<'\n';break;
case 'p':cout<<"输"<<'\n';break;}}
else if (first='p')
{switch(second)
{case 's':cout<<"输"<<'\n';break;
case 'r':cout<<"赢"<<'\n';break;
case 'p':cout<<"平"<<'\n';break;}}
else
cout<<"输入不正确"<<endl;
}
