c++语言石头剪刀布

来源:百度知道 编辑:UC知道 时间:2024/06/24 16:13:48
#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;
}
}
怎么不能用啊???
char 范围-128~127
用int 类型 能行啊/!

#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;
}
}

好厉害,向你学习。

#include "iostream.h"
int main()
{
int a,b;
while(1)
{
cout<<"剪刀(124),石头(125),布(126)"<<endl;
cout<<"甲:";
cin>>a;
cout<<