Created
May 13, 2022 14:54
-
-
Save jtprogru/e6e26d560ab5fae5ce1d056718917f7e to your computer and use it in GitHub Desktop.
Даны два числа. Найти их среднее арифметическое. На вход дается два целых положительных числа a и b. Программа должна вывести среднее арифметическое чисел a и b (ответ может быть целым числом или дробным)
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 a, b int | |
| _, _ = fmt.Scan(&a, &b) | |
| c := float32(a+b) / 2 | |
| if (a+b)%2 == 0 { | |
| fmt.Println(fmt.Sprintf("%d", int(c))) | |
| } else { | |
| fmt.Println(fmt.Sprintf("%2.1f", c)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment