a,b=input().split()
if a=='石头' and b=='剪码如弊刀':print(a)
elif a=='布' and b=='石头':print(a)
elif a=='剪刀' and b=='布':print(a)
elif a==b:print('平')
else:print(b)
我改了下,你自己看看宏李吧.#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int ren,computer
printf("0-stone,1-scissor,2-paper\n"蔽世迟)
srand(time(0))
int i = 0, sum = 0
while(i++ <= 2)
{
sum = 0
printf("Please make a choice:\n")
scanf("%d",&ren)
computer=rand()%3
printf("your choice is %d, computer's choice is %d\n"返兆, ren, computer)
if(ren==0&&computer==1)
++sum
else if(ren==1&&computer==2)
++sum
else if(ren==2&&computer==0)
++sum
else --sum
}
if(sum == 0)
printf("REPLAY!\n")
else if(sum >0)
printf("YOU WIN\n")
else if(sum <0)
printf("YOU LOST\n!")
return 0
}
帮你修改了一下判断部分。你试试吧:#include <stdio.h>
#include <stdlib.h>
#include<sys/types.h>
#include<sys/timeb.h>
main()
{
loop:
printf("欢迎来玩石头剪刀布,请使用键盘输入,岁知0代表石头,1代表剪刀,2代表布。\n******************************************************\n")
int x,com,user
unsigned int seedVal
struct timeb timeBuf
ftime(&timeBuf)
seedVal=((((unsigned int)timeBuf.time&0xFFFF)+
(unsigned int)timeBuf.millitm)^
(unsigned int)timeBuf.millitm)
srand((unsigned int)seedVal)
x=rand()
com=x%3
scanf("%d",&user)
if(user>2)
printf("您的输入有误,请输入0、1、2中任意一个数字\n")
else
{
if(com==0)
{
if(user==0) printf("平手\n")
if(user==1) printf("输了\n")
if(user==2) printf("赢了\n")
}
if(com==1)
{
if(user==0) printf("赢了\n")
if(user==1) printf("平手\n")
if(user==2) 李档printf("输了\n")
}
if(com==2)
{
if(user==0) printf("输了\n")
乎扰消 if(user==1) printf("赢了\n")
if(user==2) printf("平手\n")
}
}
goto loop
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)