#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<cstdio>
//#include<conio.h>
//#include<graphics.h>这两个头文件是C中的,C++要用,得自己写
#include<windows.h>
using namespace std;
int zhucaidan(void)
{
cout<<"a/A:石头"<<endl;
cout<<"b/B:剪刀"<<endl;
cout<<"c/C:布"<<endl;
cout<<"按Ctrl+Z退出该游戏。"<<endl;
return 0;
}
int com_chu(int j)
{
int i=0;
srand((unsigned)time(NULL));
i=rand()%3;
if(i==0)
{
cout<<"计算机出:石头"<<endl;
}
if(i==1)
{
cout<<"计算机出:剪刀"<<endl;
}
if(i==2)
{
cout<<"计算机出:布"<<endl;
}
if(j==4)
{
i+=j;return i;
}
if(j==7)
{
i+=j;return i;
}
if(j==11)
{
i+=j;return i;
}
}
int main()
{
char m;
int j=0,k=0;
zhucaidan();
cout<<endl;
while(cin>>m)
{
if(m=='a'||m=='A')
{
j=4; k=com_chu(j);
}
else if(m=='b'||m=='B')
{
j=7; k=com_chu(j);
}
else if(m=='c'||m=='C')
{
j=11; k=com_chu(j);
}
else
{ cout<<"你输入的信息错误,请按回车继续。"<<endl;k=0;
getchar();
}
if(k==5||k==9||k==10)
{
cout<<"计算机vs人:人胜"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==4||k==8||k==12)
{
cout<<"计算机vs人:平局"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==7||k==11||k==6)
{
cout<<"计算机vs人:计算机胜"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==0) getchar();
// clrscr();这是Turbo C中的函数,C++用不成
system("cls");
zhucaidan();
cout<<endl;
}
return 0;
}
#include<stdlib.h>
#include<time.h>
#include<cstdio>
//#include<conio.h>
//#include<graphics.h>这两个头文件是C中的,C++要用,得自己写
#include<windows.h>
using namespace std;
int zhucaidan(void)
{
cout<<"a/A:石头"<<endl;
cout<<"b/B:剪刀"<<endl;
cout<<"c/C:布"<<endl;
cout<<"按Ctrl+Z退出该游戏。"<<endl;
return 0;
}
int com_chu(int j)
{
int i=0;
srand((unsigned)time(NULL));
i=rand()%3;
if(i==0)
{
cout<<"计算机出:石头"<<endl;
}
if(i==1)
{
cout<<"计算机出:剪刀"<<endl;
}
if(i==2)
{
cout<<"计算机出:布"<<endl;
}
if(j==4)
{
i+=j;return i;
}
if(j==7)
{
i+=j;return i;
}
if(j==11)
{
i+=j;return i;
}
}
int main()
{
char m;
int j=0,k=0;
zhucaidan();
cout<<endl;
while(cin>>m)
{
if(m=='a'||m=='A')
{
j=4; k=com_chu(j);
}
else if(m=='b'||m=='B')
{
j=7; k=com_chu(j);
}
else if(m=='c'||m=='C')
{
j=11; k=com_chu(j);
}
else
{ cout<<"你输入的信息错误,请按回车继续。"<<endl;k=0;
getchar();
}
if(k==5||k==9||k==10)
{
cout<<"计算机vs人:人胜"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==4||k==8||k==12)
{
cout<<"计算机vs人:平局"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==7||k==11||k==6)
{
cout<<"计算机vs人:计算机胜"<<endl;getchar();
cout<<"请按回车继续"<<endl;getchar();
}
else if(k==0) getchar();
// clrscr();这是Turbo C中的函数,C++用不成
system("cls");
zhucaidan();
cout<<endl;
}
return 0;
}