Last active
June 24, 2016 13:50
-
-
Save dflima/3a3bd099bc6e53f5babdb38c540e58a0 to your computer and use it in GitHub Desktop.
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 ReadParams(size int) (params []int) { | |
| var param int | |
| for i := 0; i < size; i++ { | |
| _,err := fmt.Scanf("%d", ¶m) | |
| if err == nil { | |
| params = append(params, param) | |
| } | |
| } | |
| return params | |
| } | |
| func Sum (params []int) (sum int) { | |
| for _, v := range params { | |
| sum += v | |
| } | |
| return sum | |
| } | |
| func main() { | |
| //Enter your code here. Read input from STDIN. Print output to STDOUT | |
| var size int | |
| fmt.Scanf("%d", &size) | |
| params := ReadParams(size) | |
| sum := Sum(params) | |
| fmt.Println(sum) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment