Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added solution
  • Loading branch information
saurabh22111999 committed Oct 30, 2021
commit b48428c29f1fe869522bb3ccb51a2044e8d435f9
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
You're given the length of three sides a, b, and c respectively. Now check if these three sides can form a triangle or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).

Input:
First-line will contain three numbers a, b, and c separated by space.
Output:
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).

Constraints
1≤a,b,c≤106
Sample Input 1:
2 4 3
Sample Output 1:
YES
Sample Input 2:
1 1 4
Sample Output 2:
NO
EXPLANATION:
In the first example, (2, 4, 3) can form a triangle with an area greater than 0.
In the second example, (1, 1, 4) will never form a valid triangle.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
using namespace std;

int main()
{
int a, b, c;
cin >> a >> b >> c;
if (a + b < c a + c < b b + c < a)
cout << "NO";
else
cout << "YES";
return 0;
}