用C语言编石头剪子布程序,要求如下
Drawaflowchartandwriteagameprogram:stone,scissorsandcloth.Thecomputergeneratearandomn...
Draw a flow chart and write a game program: stone,scissors and cloth.
The computer generate a random number (1~3), 1 stand forstone, 2 stand for scissors, 3 stand for cloth.
You can input an integer number (between 1 and3) to compare with the random number. Then judge who can win. Notice pleasegive the compariso 展开
The computer generate a random number (1~3), 1 stand forstone, 2 stand for scissors, 3 stand for cloth.
You can input an integer number (between 1 and3) to compare with the random number. Then judge who can win. Notice pleasegive the compariso 展开
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int x,y,n;
srand(time(NULL));
printf("imput1-3:\n");
scanf("%d",&x);
y=rand()%3+1;
n = x-y;
if(n == 0)
printf("wahahah!\n");
else if(n == -1 || n == 2)
printf("You win\n");
else
printf("You lose");
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询