Created
December 2, 2014 07:02
-
-
Save Kairi/521ed12e521f463f65ab to your computer and use it in GitHub Desktop.
using stdin in golang
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" | |
| "bufio" | |
| "os" | |
| ) | |
| var sc = bufio.NewScannner(os.Stdin) | |
| func nextInt() int { | |
| sc.Scan() | |
| i, _ := strconv.Atoi(sc.Text()) | |
| return i | |
| } | |
| func main() { | |
| sc.Split(bufio.ScanWords) // split by space mode | |
| n := nextInt() | |
| fmt.Println(n) | |
| n := nextInt() | |
| fmt.Println(n) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment