题目如下:

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. fiddler之模拟请求超时和弱网模式

    在针对手机端测试时,很多情况下我们需要测试响应超时和弱网情况的响应情况.此时可以使用fiddler提供的断点和弱网功能进行测试. 1.请求超时 设置断点,是请求响应超时.查看请求结果. Rules-- ...

  2. 宝塔面板修改用户名和密码报错:TypeError: cannot concatenate 'str' and 'NoneType' objects

    [root@dapao~]# bt 14 正在执行(14)... ================================================================== ...

  3. springmvc中获取request对象,加载biz(service)的方法

    获取request对象: 首先配置web.xml文件--> <listener> <listener-class> org.springframework.web.con ...

  4. 一个很有意思的小游戏:Dig2China

    最近通关了一个小游戏,游戏故事是这样的:一个美国小男孩想要去中国,他决定从自家后院往下挖,横穿地心去中国,期间经历了很多次失败.但是,每次尝试都能收获一批钱,用这些钱升级钻地机,调整自己的工具,终于在 ...

  5. cocos2dx基础篇(14) 滚动视图CCScrollView

    [3.x]     (1)去掉 "CC"     (2)滚动方向         > CCScrollViewDirection 改为强枚举 ScrollView::Dire ...

  6. diff patch比较文件打补丁

    比较文件将结果保存到patch文件:diff -u test1.txt test2.txt > patchfile test1.txt应用patch文件,并备份(test1.txt.orig): ...

  7. Docker最详细入门教程

    Docker原理.详细入门教程 https://blog.csdn.net/deng624796905/article/details/86493330 阮一峰Docker入门讲解 http://ww ...

  8. [Python3] 042 日志

    目录 LOG 1. 日志相关概念 1.1 日志的级别 level 1.2 LOG 的作用 1.3 日志信息 1.4 成熟的第三方日志 1.5 注意 2. Logging 模块 2.1 日志级别 2.2 ...

  9. XLS导出的服务器端配置方式

    IIS支持excel导出: 1.开始—运行,然后键入DCOMCNFG; 2.组件服务—计算机—我的电脑—DCOM配置,这时弹出一个问注册的窗口,确定注册. 这时如果一切恢复正常了,不用往下操作了. 关 ...

  10. oracle 实现mysql find_set_in函数

    create or replace FUNCTION F_FIND_IN_SET(piv_str1 varchar2, piv_str2 varchar2, p_sep varchar2 := ',' ...