-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_inline_fn.cpp
48 lines (43 loc) · 977 Bytes
/
4_inline_fn.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by Varsha on 21-03-2023.
//
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
class triangle{
int x1,x2,x3,y1,y2,y3,l1,l2,l3;
public:
void init(){
cout<<"Enter the x coordinates:";
cin>>x1>>x2>>x3;
cout<<"Enter the y coordinates:";
cin>>y1>>y2>>y3;
}
void length(){
l1 = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
l2 = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
l3 = sqrt((x1-x3)*(x1-x3) + (y1-y3)*(y1-y3));
}
int check_validity(){
if(l1+l2>l3 && l2+l3>l1 && l3+l1>l2){
return 1;
}
else{
cout<<"Invalid triangle"<<endl;
return 0;
}
}
inline void shortest_side(){
cout<<"The shortest side is: "<<min(l1,min(l2,l3))<<endl;
}
};
int main(){
triangle t1;
t1.init();
t1.length();
if(t1.check_validity()){
t1.shortest_side();
}
return 0;
}