SQL模拟达芬奇密码中文站首页数字游戏
来源:互联网 发布:工资管理系统数据库 编辑:程序博客网 时间:2024/04/29 13:40
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
近来达芬奇密码热抄,也从网上找来看了,对中文官网首页的游戏产生了兴趣.由于是小时候看过这个数学题,现在突然看到备感亲切.所以用SQL模拟了一个.(中文官方见http://davincicode.leiling.com/)
create procdavinci(@intarrayvarchar(1000))as--******************--2004.7--******************declare@spvarchar(1)set@sp=','
declare@iint,@jint,@maxqint
--初始化ifcharindex(@sp,@intarray)=0begin ifobject_id('tempdb..##t')isnotnull droptable##t
ifisnumeric(@intarray)=0 begin print'输入参数必须是数字。' return end createtable##t(idintidentity(1,1),qint) set@i=floor(10+rand()*30) insertinto##t(q)values(@i) print'目标:'+cast(@iasvarchar(2))end
--轮回游戏elsebegin --判断游戏是否结束 ifobject_id('tempdb..##t')isnull begin print'本回合已经结束,大侠请重新来过!' return end
--验证用户输入数合法性 ifisnumeric(right(@intarray,charindex(@sp,reverse(@intarray))-1))=0 begin print'输入参数必须是数字。' return end set@i=cast(right(@intarray,charindex(@sp,reverse(@intarray))-1)asint) set@maxq=(selectmax(q)from##twhereid>1) if@i<=isnull(@maxq,0) begin print'输入参数必须大于当前最大数。' return end if@i-isnull(@maxq,1)>3 begin print'输入参数超过范围。' return end if@i>(selectqfrom##twhereid=1) begin print'输入参数不得大于目标数。' return end
--插入用户输入数 insertinto##t(q)values(@i) print'你输入:'+cast(@iasvarchar(2)) --判断胜负 if@i=(selectqfrom##twhereid=1) begin droptable##t print'-------------------------------------' print'胜败乃兵家常事,大侠请重新来过!' return end if@i=(selectqfrom##twhereid=1)-1 begin droptable##t print'达芬奇:'+cast(@i+1asvarchar(2)) print'-----------------' print'恭喜!你获胜了。' return end共2页 1
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
近来达芬奇密码热抄,也从网上找来看了,对中文官网首页的游戏产生了兴趣.由于是小时候看过这个数学题,现在突然看到备感亲切.所以用SQL模拟了一个.(中文官方见http://davincicode.leiling.com/)
create procdavinci(@intarrayvarchar(1000))as--******************--2004.7--******************declare@spvarchar(1)set@sp=','
declare@iint,@jint,@maxqint
--初始化ifcharindex(@sp,@intarray)=0begin ifobject_id('tempdb..##t')isnotnull droptable##t
ifisnumeric(@intarray)=0 begin print'输入参数必须是数字。' return end createtable##t(idintidentity(1,1),qint) set@i=floor(10+rand()*30) insertinto##t(q)values(@i) print'目标:'+cast(@iasvarchar(2))end
--轮回游戏elsebegin --判断游戏是否结束 ifobject_id('tempdb..##t')isnull begin print'本回合已经结束,大侠请重新来过!' return end
--验证用户输入数合法性 ifisnumeric(right(@intarray,charindex(@sp,reverse(@intarray))-1))=0 begin print'输入参数必须是数字。' return end set@i=cast(right(@intarray,charindex(@sp,reverse(@intarray))-1)asint) set@maxq=(selectmax(q)from##twhereid>1) if@i<=isnull(@maxq,0) begin print'输入参数必须大于当前最大数。' return end if@i-isnull(@maxq,1)>3 begin print'输入参数超过范围。' return end if@i>(selectqfrom##twhereid=1) begin print'输入参数不得大于目标数。' return end
--插入用户输入数 insertinto##t(q)values(@i) print'你输入:'+cast(@iasvarchar(2)) --判断胜负 if@i=(selectqfrom##twhereid=1) begin droptable##t print'-------------------------------------' print'胜败乃兵家常事,大侠请重新来过!' return end if@i=(selectqfrom##twhereid=1)-1 begin droptable##t print'达芬奇:'+cast(@i+1asvarchar(2)) print'-----------------' print'恭喜!你获胜了。' return end共2页 1
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- SQL模拟达芬奇密码中文站首页数字游戏
- SQL模拟达芬奇密码中文站首页数字游戏
- 关于如何进入《达芬奇密码》中文站
- 达芬奇密码
- 《达芬奇密码》
- 达芬奇密码
- 达芬奇密码
- 模拟猜数字游戏
- 达芬奇的密码
- 《达芬奇密码》中的yinhui
- * google 的达芬奇密码
- 《达芬奇密码》剧照 抢鲜看
- 达芬奇密码主题游
- google 的达芬奇密码
- 达芬奇密码图文教程
- 《达芬奇密码》读后感
- Google每日发布达芬奇密码
- 天机-破解达芬奇密码
- 男人必须明白的18个道理
- Unix文件系统研究: 3. 链接
- 关于日期天数计算的几个函数!
- A simple DirectShow example
- 什么样的女人是男人值得一辈子去珍惜的女人
- SQL模拟达芬奇密码中文站首页数字游戏
- 美国职业生涯规划与时间管理专家Brian Tracy
- 防盗器主机的原理与修理
- 随机选择表格里的行
- Unix文件系统研究: 4. 文件类型 用户权限
- 分拆统计字符串
- MINFO-印度铁矿资源矿物信息原型
- 更新字符串列表中,指定位置的字符串
- C# "未将对象引用设置到对象的实例"异常的原因 总结