Last active
March 15, 2017 17:14
-
-
Save gerep/6e8b7c9af5debf16c56b85d7337dc3bb to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" | |
) | |
func main() { | |
scanner := bufio.NewScanner(os.Stdin) | |
var lines [2]string | |
var count int | |
for scanner.Scan() { | |
lines[count] = scanner.Text() | |
count++ | |
} | |
if err := scanner.Err(); err != nil { | |
panic(err) | |
} | |
size := string(lines[0]) | |
numbers := strings.Split(string(lines[1]), " ") | |
intSize, err := strconv.Atoi(size) | |
if err != nil { | |
panic(err) | |
} | |
var total int | |
for x := 0; x < intSize; x++ { | |
intNumber, err := strconv.Atoi(numbers[x]) | |
if err != nil { | |
panic(err) | |
} | |
total += intNumber | |
} | |
fmt.Println(total) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment