-
Notifications
You must be signed in to change notification settings - Fork 1
/
triangle-procedure-with-instrument.go
42 lines (38 loc) · 1.22 KB
/
triangle-procedure-with-instrument.go
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
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
fmt.Println("[S] Start application.\n[S] Converting args to int.")
a, _ := strconv.Atoi(os.Args[1])
b, _ := strconv.Atoi(os.Args[2])
c, _ := strconv.Atoi(os.Args[3])
fmt.Println("[S] Converted args to int.")
if a <= 0 || b <= 0 || c <= 0 {
fmt.Println("[!] All 3 arguments must be positive value.")
} else if a > 200 || b > 200 || c > 200 {
fmt.Println("[!] There is some value is out of range.")
} else if a+b <= c && a+c <= b && b+c <= a {
fmt.Println("[!] Not a triangle.")
} else {
fmt.Println("[S] Values can posible be triangle.")
fmt.Println("[S] Power 2 all values to prepare Right Triangle.")
aPow2 := a * a
bPow2 := b * b
cPow2 := c * c
fmt.Println("[S] Power 2 all values finished.")
if aPow2+bPow2 == cPow2 || aPow2+cPow2 == bPow2 || bPow2+cPow2 == aPow2 {
fmt.Println("[A] Right Triangle.")
} else if a == b && b == c {
fmt.Println("[A] Equilateral.")
} else if a == b && a+b > c || a == c && a+c > b || b == c && b+c > a {
fmt.Println("[A] Isosceles.")
} else if a != b && a != c && b != c {
fmt.Println("[A] Scalene.")
}
fmt.Println("[S] Finished check triangle type.")
}
fmt.Println("[S] End of application.")
}