当前位置:首页 > 代码 > 正文

剪刀石头布小游戏代码(石头剪刀布游戏名称)

admin 发布:2022-12-19 18:43 166


今天给各位分享剪刀石头布小游戏代码的知识,其中也会对石头剪刀布游戏名称进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

求:用asp写剪刀石头布小游戏的代码

给你举个例子,你运行一下,再看一看就明白其中的原理,然后你就可以修改成你要的样子了:

!--这个页面的文件名叫tmp.asp--

html

body%

id=trim(Request.QueryString("id"))

if isNumeric(id) then

id=cint(id)

if id=0 and id=2 then

dim dn(2)

dn(0)="石头":dn(1)="剪刀":dn(2)="布"

randomize

tmp=int(rnd*3)

response.write "script lanuage=""javascript""alert(""您出的是【"dn(id)"】,电脑出的是【"dn(tmp)"】,您"

if idtmp and not(id=0 and tmp=2) then

response.write "赢"

elseif id=tmp then

response.write "平"

else

response.write "输"

end if

response.write "了!"")/script"

end if

end if

%

请点击您的选择:

input value="石头" type="button" style="width:50px" onClick="window.location.href='tmp.asp?id=0'"/input

input value="剪刀" type="button" style="width:50px" onClick="window.location.href='tmp.asp?id=1'"/input

input value="布" type="button" style="width:50px" onClick="window.location.href='tmp.asp?id=2'"/input

/body

/html

c语言剪刀石头布小游戏

#include stdio.h

#include stdlib.h

#include time.h

int main()

{

char m; //表示选择的是哪个人

int a,b; //分别表示人和电脑

printf("(J)iandao, (S)hitou, hu(B)u :\n");

scanf("%c",m);

if(m!='J' m!='S' m!='B')

printf("Input error!\n");

else //分别用0,1,2代表石头,剪刀,布

{

srand(time(NULL));

a = rand()%3;

switch(a)

{

case 0:

printf("人出的是石头\n");

break;

case 1:

printf("人出的是剪刀\n");

break;

case 2:

printf("人出的是布\n");

break;

default:

break;

}

b = rand()%3;

switch(b)

{

case 0:

printf("电脑出的是石头\n");

break;

case 1:

printf("电脑出的是剪刀\n");

break;

case 2:

printf("电脑出的是布\n");

break;

default:

break;

}

if(a b)

printf("人赢了!\n");

else if(a == b)

printf("平局!\n");

else

printf("电脑赢了!\n");

}

return 0;

}

石头剪刀布python编程代码

player = int(input(“请出拳 石头(1)/剪刀(2)/布(3)”))

computer = 1

if((player == 1 and computer == 2) or

(player == 2 and computer == 3) or

(player == 3 and computer == 1)):

print(“欧耶!电脑弱爆了!”)

elif player == computer:

print(“心有灵犀,再来一盘!”)

else:

print(“不行,我要和你决战到天明!”)

执行的时候,第一行一定要单独复制,因为你需要输入一个数值

跪求C#剪刀石头布简单代码及解释

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;namespace 剪刀

{

class Program

{

static void Main(string[] args)

{

int i;

Console.WriteLine("你出啥子,输入0为剪刀。1为帕子。2为石头");

int diannao = 0, wanjia = 0;

while(true)

{

i = Console.Read(); Console.Read(); Console.Read();//read后面自动加\r\n所以要加两个来吸收

int c = panduan(i);

if (c== 0)

{

Console.WriteLine("电脑赢了");

diannao++;

}

else if (c== 1)

{

Console.WriteLine("你赢了");

wanjia++;

}

Console.WriteLine("你赢了"+wanjia+"次"+"电脑赢了"+diannao+"次");

Console.WriteLine();

if (diannao == 3|| wanjia == 3)

{

Console.WriteLine("game over");

return;

}

}

}

static int panduan(int i)

{

int c;

string [] s=new string[3];

s[0] = "剪刀";

s[1] = "帕子";

s[2] = "石头";

if (i 48 || i 50)

{

Console.WriteLine("乱输嘛,算你输"+i);

return 0;

}

Console.WriteLine("你的输入时" + s[i-48]);

Random a = new Random();

c = a.Next(48,50);

Console.WriteLine("电脑出的是"+s[c-48]);

if(i==c)

{

return 2 ;

}

if (i == 48 c == 49 || i == 49 c == 50 || i == 50 c == 48)

return 1;

else

return 0;

}

}

}

关于剪刀石头布小游戏代码和石头剪刀布游戏名称的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/18222.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载