package main
import "fmt"
func main() {
a := [...]int {1, 2, 3, 4, 5, 6, 7 ,8, 9, 10}
for i :=range a {
if a[i] % 2 == 0 {
fmt.Println(a[i] / 2)
}
}
}
Last active
December 21, 2015 22:38
-
-
Save iambowen/6376234 to your computer and use it in GitHub Desktop.
go implementation
XuefengWu
commented
Aug 29, 2013
package main
import "fmt"
func main(){
pow := make([]int, 10)
for i:=range pow {
pow[i] = i+1
fmt.Printf("%d\t",pow[i])
}
fmt.Printf("\n")
result := make([]int, 5)
index := 0
for i:=range pow {
if (pow[i]%2 == 0){
result[index] = pow[i]
fmt.Printf("%d\t",result[index])
index++
}
}
fmt.Printf("\n")
for i:=range result {
fmt.Printf("%d\t",result[i]/2)
}
fmt.Printf("\n")
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment