解题思路:
注意事项:
参考代码:
#include
typedef enum _peak{stone,cloth,scissor} peak;
typedef enum _result{win,loss,even} result;
peak match( int x)
{
if( x == 0)
return stone ;
else if( x == 1)
return cloth ;
else
return scissor ;
}
result combat( peak x,peak y)
{
if((x == stone && y == cloth) || (x == cloth && y == scissor) ||(x == scissor && y == stone))
return loss ;
else if((x==cloth && y==stone) || (x == scissor && y == cloth) ||(x == stone && y == scissor))
return win ;
else if( (x==cloth && y==cloth) || (x == scissor && y == scissor) ||(x == stone && y == stone))
return even ;
}
int main()
{
peak a,b;
int s0,s1 ;
scanf("%d %d",&s0,&s1);
a = match(s0);
b = match(s1);
if( combat(a,b) == win)
printf("1");
else if( combat(a,b) == loss)
printf("-1");
else
printf("0");
return 0;
}