SHARE
TWEET

Untitled

a guest Jan 24th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "os"
  7.     "strconv"
  8.     "strings"
  9. )
  10.  
  11. type  (
  12.     tRow []int
  13.     tData2 []tRow
  14. )  
  15.  
  16. func main() {
  17.     var (
  18.         a   tData2
  19.         c   tRow
  20.         row int
  21.     )
  22.  
  23.     // Чтение данных из файла 2D.dat
  24.     fin, _ := os.Open("2D.dat")
  25.     defer fin.Close()
  26.  
  27.     for scanner := bufio.NewScanner(fin); scanner.Scan(); row++ {
  28.         if scanner.Text() == "" {
  29.             break
  30.         }
  31.         c = make([]int, 0)
  32.         for _, snum := range strings.Fields(scanner.Text()) {
  33.             if x, err := strconv.Atoi(snum); err == nil {
  34.                 c = append(c, x)
  35.             }
  36.         }
  37.         fmt.Printf("Row #%2d: %v\n", row, c)
  38.         a = append(a, c)
  39.     }
  40.     fmt.Println(a)
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top