Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "os"
- "fmt"
- "bufio"
- "strconv"
- )
- func doubler(v int, ch chan int) {
- ch <- v * 2
- }
- func main() {
- var num string
- file, _ := os.Open("IN.A")
- out, _ := os.Create("OUT")
- defer out.Close()
- s := bufio.NewScanner(file)
- c := make(chan int)
- for s.Scan() {
- num = s.Text()
- numi, _ := strconv.ParseInt(num, 0, 0)
- go doubler(int(numi), c)
- out.WriteString(fmt.Sprintf("%d\n",int(<-c)))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement