Skip to content

Instantly share code, notes, and snippets.

@Kairi
Created December 2, 2014 07:02
Show Gist options
  • Select an option

  • Save Kairi/521ed12e521f463f65ab to your computer and use it in GitHub Desktop.

Select an option

Save Kairi/521ed12e521f463f65ab to your computer and use it in GitHub Desktop.
using stdin in golang
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