Skip to content

Instantly share code, notes, and snippets.

@jtprogru
Created May 13, 2022 14:54
Show Gist options
  • Select an option

  • Save jtprogru/e6e26d560ab5fae5ce1d056718917f7e to your computer and use it in GitHub Desktop.

Select an option

Save jtprogru/e6e26d560ab5fae5ce1d056718917f7e to your computer and use it in GitHub Desktop.
Даны два числа. Найти их среднее арифметическое. На вход дается два целых положительных числа a и b. Программа должна вывести среднее арифметическое чисел a и b (ответ может быть целым числом или дробным)
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