题目如下:

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. kafka多线程消费

    建立kafka消费类ConsumerRunnable ,实现Runnable接口: import com.alibaba.fastjson.JSON; import com.alibaba.fastj ...

  2. spotlight监控linux性能

    linux性能监控有很多工具,spotlight只是其中一种 目录 1.安装spotlight 2.参数认识 1.安装spotlight spotlight不仅仅只是监控linux,还可以完成数据库以 ...

  3. 一种局部二值化算法:Sauvola算法

    之前接触过全局二值化(OTSU算法),还有OPENCV提供的自适应二值化,最近又了解到一种新的局部二值化算法,Sauvola算法. 转载自:http://www.dididongdong.com/ar ...

  4. laravel 多字段登录

    protected function validateChinaPhoneNumber($number) { return preg_match('/^1[34578]\d{9}$/', $numbe ...

  5. 2.nginx配置详细说明

    Nginx配置详解 nginx概述 nginx是一款自由的.开源的.高性能的HTTP服务器和反向代理服务器:同时也是一个IMAP.POP3.SMTP代理服务器:nginx可以作为一个HTTP服务器进行 ...

  6. spark MLlib矩阵四则运算,线性代数

    1.导包请看我的上一篇博文,maven项目的包 https://www.cnblogs.com/wuzaipei/p/10965680.html 2.denseMatirx 矩阵四则运算如下 版本不同 ...

  7. Miller-Robin 素数测试法 模板

    测试单个素数,出错概率比计算机本身出错的概率还要低 算法是基于费马小定理(format),二次探测定理(x*x % p == 1 ,若P为素数,则x的解只能是x = 1或者x = p - 1)加上迭代 ...

  8. Quartz-第三篇 quartz-misfire 错失,补偿执行

    1.问题:使用pauseJob()后,再使用resumeJob(). Job如果中间时间足够短,默认会将之前错失的次数执行回来.这个问题的原因是执行调度策略的问题,quartz框架默认会将错失的执行次 ...

  9. vue点击除了某组件本身的其它地方, 隐藏该组件的方法

    点击emoji表情标签, 出现标签组件,点击其它地方, 改组件消失的效果; <template> <div class="writeZoon"> <d ...

  10. JS事件绑定的两种形式

    第一种: obj.on*=function(){} var btn=document.getElementById('myBtn'); btn.onclick=function(){ alert(1) ...