题目如下:

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:

  • Equilateral: It's a triangle with  sides of equal length.
  • Isosceles: It's a triangle with  sides of equal length.
  • Scalene: It's a triangle with  sides of differing lengths.
  • Not A Triangle: The given values of A, B, and C don't form a triangle.

Input Format

The TRIANGLES table is described as follows:

Each row in the table denotes the lengths of each of a triangle's three sides.

Sample Input

Sample Output

Isosceles
Equilateral
Scalene
Not A Triangle

Explanation

Values in the tuple  form an Isosceles triangle, because . 
Values in the tuple  form an Equilateral triangle, because . Values in the tuple  form a Scalene triangle, because . 
Values in the tuple  cannot form a triangle because the combined value of sides  and  is not larger than that of side .

解题思路:主要是根据三个边长之间的关系来判断三角形的种类,注意判断的顺序是:不是三角形,等边三角形,等腰三角形,其他三角形。

代码如下:

/*
Enter your query here.
*/
select
case
when (A+B) <= C or (A+C) <= B or (B+C) <= A then 'Not A Triangle'
when (A=B) and (B=C) and (A=C) then 'Equilateral'
when (A=B) or (A=C) or (B=C) then 'Isosceles'
else 'Scalene'
END
from
TRIANGLES;

【hackerrank】Type of Triangle的更多相关文章

  1. 【LeetCode】Pascal's Triangle II 解题报告

    [LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...

  2. 【Leetcode】【Easy】Pascal's Triangle

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  3. 【LeetCode】611. Valid Triangle Number 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/valid-tri ...

  4. 【LeetCode】812. Largest Triangle Area 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 三重循环 组合函数 日期 题目地址:https:// ...

  5. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  6. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  7. 【leetcode】Pascal's Triangle I & II (middle)

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  8. 【python】type()、instance()

    >>> a=520 >>> type(a) <class 'int'> >>> a=' >>> type(a) &l ...

  9. 【HackerRank】How Many Substrings?

    https://www.hackerrank.com/challenges/how-many-substrings/problem 题解 似乎是被毒瘤澜澜放弃做T3的一道题(因为ASDFZ有很多人做过 ...

随机推荐

  1. 移动端自动化==>Windows-Android-Appium环境搭建

    第一步 安装JDK,本机如果带有1.7及以上版本且配置好了环境变量,则可忽略此安装步骤. JDK的安装包,百度下载即可.安装完成后配置环境变量. cmd下验证环境变量是否配置成功 第二步 安装Andr ...

  2. 关于win10系统如何调用debug查看CPU汇编指令和内存

    下载安装DOSBox.网上提供下载地址:DOSBOX Debug是DOS(Disk Operating System,磁盘操作系统).windows提供的实模式(8086方式)程序的调试工具.使用它, ...

  3. C++:利用如下公式,编写函数计算∏的值,直到最后一项的绝对值小于e,主程序接收从键盘输入的e,输出∏的值(保留5位小数)。 ∏/4 = 1-1/3+1/5-1/7...

    利用如下公式,编写函数计算∏的值,直到最后一项的绝对值小于e,主程序接收从键盘输入的e,输出∏的值(保留5位小数). ∏/4 = 1-1/3+1/5-1/7... #include <iostr ...

  4. MACBOOK蓝牙连接丢失恢复

    MACBOOK用户可能会碰到一个神奇而无奈的问题: 某些情况下,很多时候从睡眠状态回来,会发现蓝牙设备再也无法连接,包括蓝牙鼠标.键盘等等... 恢复方法一般是,重启或注销后重新登陆,然后所有工作现场 ...

  5. cocos2dx基础篇(17) 音乐音效SimpleAudioEngine

    [3.x]     (1)获取单例:sharedEngine() 改为 getInstance()     (2)实现了:音量的调节.     (3)修改了播放音效 playEffect() 的参数: ...

  6. Git 创建分支并合并主分支

    首先,我们创建dev分支,然后切换到dev分支: $ git checkout -b dev(等价于 $ git branch dev $ git checkout dev ) Switched to ...

  7. 题解 CF978C 【Letters】

    此题评测机出了点问题,数据全部AC,却显示UKE 下面是数据全部AC,却显示UKE的代码 思路:b[i]减去每个宿舍的房间总数,如果b[i]小于了某个宿舍的房间总数则为答案. #include< ...

  8. TCP滑动窗体

    TCP的滑动窗体攻克了端到端的流量控制问题,同意接受方对传输进行限制.直到它拥有足够的缓冲空间来容纳很多其他的数据.滑动窗体的大小由接收方确定,接收方在发送确认信号给发送方的同一时候告诉发送方自己的缓 ...

  9. go & Windows Service

    相关库 https://godoc.org/golang.org/x/sys/windows/svc https://github.com/kardianos/service https://gith ...

  10. jQuery实现动态时间

    <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8& ...