#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	srand((unsigned)time(NULL));
	char ch=0;
	int comp=0;
	int man=0;
	char * s[]={"石头","剪子","布"};
	while(1)
	{
		fflush(stdin);
		system("cls");
		printf("请选择你要出的拳头:\n");
		printf("A:石头\n");
		printf("B:剪子\n");
		printf("C:布\n");
		printf("D:退出\n");
		scanf("%c",&ch);
		if(ch=='d' || ch=='D') break;
		comp=rand()%3;
		if(ch=='a' || ch=='A') man=0;
		if(ch=='b' || ch=='B') man=1;
		if(ch=='c' || ch=='C') man=2;
		if(comp-man==0) printf("电脑出的是%s  平局\n",s[comp]);
		if((comp-man==-1) || (comp-man==2)) printf("电脑出的是%s  电脑胜出\n",s[comp]);
		if((comp-man==1) || (comp-man==-2) ) printf("电脑出的是%s  楼主胜出\n",s[comp]);
		system("pause");
	}
	return 0;
}