-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle.cpp
More file actions
36 lines (34 loc) · 736 Bytes
/
Triangle.cpp
File metadata and controls
36 lines (34 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
int main(void){
int i,arr[4],tri=0,seg=0,j,u,v,x;
for(i=0;i<4;i++){
cin>>arr[i];
}
sort(arr,arr+4);
for(i=0;i<2;i++){
for(j=i+1;j<3;j++){
if(arr[i]+arr[j] > arr[j+1]){
u=arr[i];
v=arr[j];
x=arr[j+1];
if((u+x>v) && (v+x>u)){
tri++;
break;
}
}
else if(arr[i]+arr[j] == arr[j+1]){
seg++;
}
}
}
if(tri>0){
cout<<"TRIANGLE"<<endl;
}
else if(seg>0){
cout<<"SEGMENT"<<endl;
}
else{
cout<<"IMPOSSIBLE"<<endl;
}
}