文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 国产软件 | 国外软件 | 汉化补丁 | 设为首页 | 加入收藏
业界资讯 | 图形图像 | 操作系统 | 网络冲浪 | 工具软件 | 办公软件 | 媒体动画 | 精文荟萃 | 认证考试 | 网站建设 | 技术开发 | 专栏
当前位置:abcdown网络学院程序开发OracleSQL模拟达芬奇密码中文站首页数字游戏
精品广告
推荐TOP10
·常用数据库比较
·ODBC API常用函数诠释
·提高ORACLE数据库的查询统计速度
·细化解析:Oracle使用的hints调整机制
·解析Oracle/Oracle Forms 的多用途代码
·从Oracle的FORM中调用REPORT的实用技巧
·Oracle SQL精妙SQL语句讲解
·ORACLE学习笔记--性能优化四
·ORACLE常用傻瓜问题1000问
·ORACLE常见错误代码的分析与解决之二
阅读TOP10
·详细介绍ORACLE sqlplus命令
·ORACLE中LONG类型字段的存取
·PL/Sql循序渐进全面学习教程
·Oracle SQL精妙SQL语句讲解
·细化解析:Oracle使用的hints调整机制
·破解Oracle中国高层频繁变动之谜
·监控Oracle数据库的常用shell脚本
·ORACLE数据库傻瓜手册
·ORACLE常用傻瓜问题1000问
·ORACLE傻瓜手册长篇连载

SQL模拟达芬奇密码中文站首页数字游戏

日期:2007年7月2日 作者: 查看:[大字体 中字体 小字体]



  近来达芬奇密码热抄,也从网上找来看了,对中文官网首页的游戏产生了兴趣.由于是小时候看过这个数学题,现在突然看到备感亲切.所以用SQL模拟了一个.(中文官方网站见http://davincicode.leiling.com/)
  
  create proc davinci (@intarray varchar(1000))as--******************--2004.7--******************declare @sp varchar(1)set @sp=','
  
  declare @i int,@j int,@maxq int
  
  --初始化if charindex(@sp,@intarray)=0begin  if object_id('tempdb..##t') is not null   drop table ##t
  
  if isnumeric(@intarray)=0  begin   print '输入参数必须是数字。'   return  end  create table ##t(id int identity(1,1),q int)  set @i=floor(10+rand()*30)  insert into ##t(q) values(@i)  print '目标:'+cast(@i as varchar(2))end
  
  --轮回游戏elsebegin
  
  --判断游戏是否结束  if object_id('tempdb..##t') is null  begin   print '本回合已经结束,大侠请重新来过!'   return  end
  
  --验证用户输入数合法性  if isnumeric(right(@intarray,charindex(@sp,reverse(@intarray))-1))=0  begin   print '输入参数必须是数字。'   return  end  set @i=cast(right(@intarray,charindex(@sp,reverse(@intarray))-1) as int)  set @maxq=(select max(q) from ##t where id>1)  if @i<=isnull(@maxq,0)  begin   print '输入参数必须大于当前最大数。'   return  end  if @i-isnull(@maxq,1)>3  begin   print '输入参数超过范围。'   return  end  if @i>(select q from ##t where id=1)  begin   print '输入参数不得大于目标数。'   return  end
  
  --插入用户输入数  insert into ##t(q) values(@i)  print '你输入:'+cast(@i as varchar(2))  --判断胜负  if @i=(select q from ##t where id=1)  begin   drop table ##t ----------------------------------'   print '胜败乃兵家常事,大侠请重新来过!'   return  end  if @i=(select q from ##t where id=1)-1  begin  drop table ##t   print '达芬奇:'+cast(@i+1 as varchar(2))   print '-----------------'   print '恭喜!你获胜了。'   return  end
  
  --插入达芬奇应答数  if (select q-1 from ##t where id=1)%4=0   set @j=(select count(id) from ##t where id%2=1)*4  else  begin   set @j=(select q-1 from ##t where id=1)%4+((select count(id) from ##t where id%2=1)-1)*4   if @j<(select max(q) from ##t where id>1)     set @j=@j+4  end   if @i=@j   set @j=@j+floor(1+rand()*3)  insert into ##t values(@j)  print '达芬奇:'+cast(@j as varchar(2))end
  
  --完整版显示select 目标数=q,你输入=null,达芬奇=null,下次输入='1,2,3' from ##t where id=1union allselect 目标数=null,你输入,达芬奇  ,下次输入=case when charindex(','+目标数+',',','+下次输入+',')=0 then 下次输入 else  left(left(下次输入,charindex(','+目标数+',',','+下次输入+',')+len(目标数)),  len(left(下次输入,charindex(','+目标数+',',','+下次输入+',')+len(目标数)))-  charindex(',',reverse(left(下次输入,charindex(','+目标数+',',','+下次输入+',')+len(目标数)))))  endfrom (select 目标数,你输入,达芬奇  ,下次输入=cast(达芬奇+1 as varchar(2))+','   +cast(达芬奇+2 as varchar(2))+','   +cast(达芬奇+3 as varchar(2))from (select 目标数=cast((select q from ##t where id=1) as varchar(2))  ,你输入=max(case when id%2=0 then q else 0 end)  ,达芬奇=max(case when id%2=1 then q else 0 end)from ##twhere id>1group by floor(id/2)) a) b
  
  /*--简化版显示select case when id=1 then '目标数:'  when id%2=0 then '你输入:'  when id%2=1 and id>1 then '达芬奇:' end  ,qfrom ##t*/
  
  游戏规则:系统随机产生目标数,双方从数字1开始轮回应答,数字必须连续,每回合最多可以选择3个数字,先到目标数者为负。
[1] [2] 下一页 

上一篇:数据库设计中的反规范技术探讨

下一篇:Oracle调优(入门及提高篇)


相关软件: 相关文章:
·SQL模拟达芬奇密码中文站首页数字游戏

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.abcdown.net
首页 | 本站声明 | 下载帮助 | 发布软件 |
中文版权所有:ABC学院 浙ICP备05000717号