Created
May 13, 2022 14:33
-
-
Save jtprogru/268ee036a47ff65a9af93e1876e6d903 to your computer and use it in GitHub Desktop.
Даны три натуральных числа a, b, c. Определите, существует ли треугольник с такими сторонами.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var inputNumbers = make([]int, 3, 3) | |
_, _ = fmt.Scan(&inputNumbers) | |
for i := range inputNumbers { | |
_, _ = fmt.Scan(&inputNumbers[i]) | |
} | |
if rightTriangle(inputNumbers...) { | |
fmt.Println("Существует") | |
} else { | |
fmt.Println("Не существует") | |
} | |
} | |
func rightTriangle(nums ...int) bool { | |
if (nums[0]+nums[1] > nums[2]) && (nums[1]+nums[2] > nums[0]) && (nums[0]+nums[2] > nums[1]) { | |
return true | |
} else { | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment