石头剪子布的游戏

大家小时候都玩过石头剪子布的游戏吧,出石头的人赢出剪子的人,
出剪子的人赢出布的人,出布的人赢出石头的人,如果两个人出的一样,则打平。
飞燕姐姐和婷婷玩石头剪子布的游戏,请你写一个程序判断一下谁赢了


输入:
石头用stone表示,剪子用scissors表示,布用cloth表示
飞燕姐姐和婷婷出的用空格隔开
以EOF结束


输出:
飞燕姐姐赢了则输出yzfy wins!
婷婷赢了则输出wtthappy wins!
打平则输出The game ends in a draw.
谁出错了就判另一方赢,大家都出错了就和


样例输入:
stone cloth
stone stone
stone scissors
scissor stone
stome scissor


样例输出:
wtthappy wins!
The game ends in a draw.
yzfy wins!
wtthappy wins!

The game ends in a draw.

// ct10_3.cpp : Defines the entry point for the console application.
//

#define PB_ID ct10_3
#define CP_VC6P

#include "stdafx.h"
#include "stdio.h"
#include "string.h"
int transform(char *input)
{
	if ( strcmp(input,"stone")== 0)         return  1;
	else if ( strcmp(input,"scissors")== 0) return  2;
	else if ( strcmp(input,"cloth")== 0)    return  3;
	else return 0;
}



int main(int argc, char* argv[])
{
	char p1[10], p2[10];
	int  n1, n2;
	while( (scanf("%s%s",p1,p2))!= EOF)
	{
	if ((n1 = transform(p1))==0 ) {printf("input error\n"); continue;}
	if ((n2 = transform(p2))==0)  {printf("input error\n"); continue;}
	if (n1 == n2) {printf("The game ends in a draw\n"); continue;}
	switch (n1)
	{ case 1:
		{  if (n2 == 2) 
			{
				printf("yzfy wins\n"); 
				continue;
			}
			else  
			{
				printf("wtthappy wins\n"); 
				continue;
			}
		}
    case 2:
		{  if (n2 == 1) 
			{
				printf("wtthappy wins\n"); 
				continue;
			}
			else  
			{
				printf("yzfy wins\n"); 
				continue;
			}
		}
    case 3: 		
		{  if (n2 == 1) 
			{
				printf("yzfy wins\n"); 
				continue;
			}
			else  
			{
				printf("yzfy wins\n"); 
				continue;
			}
		}
	}
	}

	return 0;
}




你可能感兴趣的:(算法,vc++6.0)