c++语言石头剪刀布

2023-10-07 17:35:44

#include "iostream.h"
void main()
{
char a,b;
while(1)
{
cout<<"剪刀(124),石头(125),布(126)"<<endl;
cout<<"甲:"<<endl;
cin>>a;
cout<<"乙:"<<endl;
cin>>b;
if(a==b)continue;
}
if(a!=124||b!=124)
{
if(a>b)
cout<<"甲赢"<<endl;
else
cout<<"乙赢"<<endl;
}
else
{
a+=2;b+=2;
if(a>b)
cout<<"甲赢"<<endl;
else
cout<<"乙赢"<<endl;
}
}
怎么不能用啊???

好评回答
#include "iostream.h"
void main()
{
int a,b; //整形
while(1)
{
cout<<"剪刀(124),石头(125),布(126)"<<endl;
cout<<"甲:";
cin>>a;
cout<<"乙:";
cin>>b;
if(a==b)
cout<<"平局"<<endl;
else break;//原来是死循环
}
if(a!=124||b!=124)
{
if(a>b)
cout<<"甲赢"<<endl;
else
cout<<"乙赢"<<endl;
}
else
{
a+=2;b+=2;
if(a>b)
cout<<"甲赢"<<endl;
else
cout<<"乙赢"<<endl;
}
}