0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Go言語で平均を出すコード

Last updated at Posted at 2022-04-04
Goで平均を出すだけのコード
package main

import "fmt"

func avg(num []int) int {
	goukei := 0
	count := 0
	for {
		goukei = goukei + num[count]
		if count == len(num)-1 {
			return goukei / count
		}
		count ++
	}
}

func main() {
	keisan := []int{34,56,23}//ここに値
	x := avg(keisan)
	fmt.Println("平均:",x)
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?