Multiple Dwellings
Baker, Cooper, Fletcher, Miller and Smith live on different floors of an apartment house that contains only five floors.
Baker does not live on the top floor. Cooper does not live on the bottom floor.
Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper.
Smith does not live on a floor adjacent to Fletcher’s.
Fletcher does not live on a floor adjacent to Cooper’s. Where does everyone live?

--Baker, Cooper, Fletcher, Miller and Smith住在一座房子的不同楼层.

--Baker 不住顶层.

--Cooper不住底层.

--Fletcher 既不住顶层也不住底层.
--Miller住得比Cooper高.
--Smith住的楼层和Fletcher不相邻.
--Fletcher住的楼层和Cooper不相邻.

 
select*from
(select (number) Baker from master.dbo.spt_values where type='P' and number between 1 and 5 ) as a,
(select (number) Cooper from master.dbo.spt_values where type='P' and number between 1 and 5 ) as b,
(select (number) Fletcher from master.dbo.spt_values where type='P' and number between 1 and 5 ) as c ,
(select (number) Miller from master.dbo.spt_values where type='P' and number between 1 and 5 ) as d,
(select (number) Smith from master.dbo.spt_values where type='P' and number between 1 and 5 ) as e
where
Baker<>5 and
Cooper<>1 and
Fletcher not in (1,5) and
Miller>Cooper and
abs(Smith-Fletcher)<>1 and
abs(Fletcher-Cooper)<>1
and Baker<>Cooper
and Baker<>Fletcher
and Baker<>Miller
and Baker<>Smith
and Cooper<>Fletcher
and Cooper<>Miller
and Cooper<>Smith
and Fletcher<>Miller
and Fletcher<>Smith
and Smith<>Miller

查询结果

SQL谜题(楼层谜题)的更多相关文章

  1. Java谜题——库谜题

    1.Java中的不可变对象和可变对象 (1)不可变类:当你获得这个类的实例的引用之后,你不可以改变这个实例的内容.比如:String,BigInteger,BigDecimal,还有基本数据类型的封装 ...

  2. Java谜题——类谜题(二)

    1.域的隐藏 代码如下: class Base { public String className = "Base"; } class Derived extends Base { ...

  3. [TJOI2015] 棋盘

    Description 为了提高智商,ZJY去新世界旅游了.可是旅游过后的ZJY杯具的发现要打开通往原来世界的门,必须要解开门上面画的谜题.谜题是这样的:有个\(n\)行\(m\)列的棋盘,棋盘上可以 ...

  4. 比特币运行原理[z]

    https://baijiahao.baidu.com/s?id=1581755535769652543&wfr=spider&for=pc 这篇文章主要讲解比特币是什么?它的运行原理 ...

  5. 【nodejs】理想论坛帖子下载爬虫1.07 使用request模块后稳定多了

    在1.06版本时,访问网页采用的时http.request,但调用次数多以后就问题来了. 寻找别的方案时看到了https://cnodejs.org/topic/53142ef833dbcb076d0 ...

  6. nodejs源码—初始化

    概述 相信很多的人,每天在终端不止一遍的执行着node这条命令,对于很多人来说,它就像一个黑盒,并不知道背后到底发生了什么,本文将会为大家揭开这个神秘的面纱,由于本人水平有限,所以只是讲一个大概其,主 ...

  7. SQL 谜题(硬币的组合)

    问题:早在ITPUB中看过有个SQL高手,喜欢出谜题,以下是一个谜题.我试用SQL SERVER解决此问题. 用1分,5分,10分,25分,50分硬币凑成一元,总共有几种组合办法? SELECT'1* ...

  8. SQL谜题(加减符号替代)

    问题:将以下字符串”.1.2.3.4.5.6.7.8.9 = 1“中的符号点(.)更改为符号加(+)或符号(-),有多少种方法?请用SQL解决此问题 计算过程: CREATE TABLE #(VAL ...

  9. SQL 谜题(父亲的邮票)

    问题:父亲需要些1分,2分,3分,5分,10分的邮票, 其中两种各买四张,另外的三种各买三张 我忘记是哪几种了?他给了我一些10分硬币,金额刚好买这些邮票 计算及分析过程: --通过极限算法,若都是3 ...

随机推荐

  1. thinkphp添加数据

    <?php namespace Admin\Controller; use Think\Controller; class MainController extends Controller { ...

  2. linux 卸载编译安装的软件

    有些软件会有 make uninstall 之类的功能,但大多都没有,所以只有手动删除,或者在configure的时候加个preifx参数,比如 --preifx=/opt/squid,这样当你不用的 ...

  3. Eclipse Android环境搭建

    1.先安装ADT,记得断开网络2.然后关闭Eclipse安装SDK,例如安装在C:\Users\Administrator\AppData\Local\Android\android-sdk3.重启E ...

  4. 查看npm全局安装的模块

    1.查看所有高级的npm moudles npm list --depth= 2.查看所有全局安装的模块 npm list --depth= -global

  5. JS阻止冒泡事件以及默认事件发生的简单方法

    如果<p>是在<div>里面,那么呢,<P>有一个onclick事件,<div>也有onclick事件,为了触发<P>的点击事件时,不触发父 ...

  6. NetBean 8 创建EJB

    一. 介绍 百度了一下关于在NetBean开发环境里创建EJB的教程,没有找到好的例子,2天的调试过程,写下来帮助后人. EJB (Enterprise Java Bean) 是一套高扩展性的开发企业 ...

  7. Visual Studio EventHandler Delegate 和 EventArgs

    EventHandler代理 用来表示处理一个没有事件数据(event data)的事件(event)的 方法. 无论何时事件发生时,事件代理就被调用来触发以前事件驱动的其他事件(监听当前事件TCur ...

  8. 关于li元素嵌套的事儿

    今天阅读<锋利的jQuery>第二版2.6节案例研究部分的时候,遇到一个问题. <ul> <li class="a1"><a href=& ...

  9. 编程轶事-java中的null-遁地龙卷风

    1.null是个奇妙的东西,可以理解为对象占位符 User user = null; System.out.println(user.getCredits()); 可以通过编译, User user; ...

  10. Eclipse使用Maven tomcat:run命令启动web项目时修改默认端口