Untitled
unknown
golang
5 months ago
525 B
4
Indexable
package main import "fmt" const pi float64 = 3.14 type Bola struct { nama string jari int volume float64 } func pangkat3(x int) float64 { return } func main() { var bola [5]Bola for i := 0; i < 5; i++ { fmt.Scan(&bola[i].nama, &bola[i].jari) bola[i].volume = (4.0 / 3.0) * pi * float64(bola[i].jari * bola[i].jari * bola[i].jari) } maxIndex := 0 for i := 1; i < 5; i++ { if bola[i].volume > bola[maxIndex].volume { maxIndex = i } } fmt.Println(bola[maxIndex].nama, bola[maxIndex].volume) }
Editor is loading...
Leave a Comment