本文整理汇总了Golang中fmt.Scanf函数的典型用法代码示例。如果您正苦于以下问题:Golang Scanf函数的具体用法?Golang Scanf怎么用?Golang Scanf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Scanf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    arr := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &arr[i])
    }
    var i, j, l, cnt int
    arrLen := n
    for cnt = 0; ; cnt++ {
        j = 0
        for i, l = 1, arrLen; i < l; i++ {
            if arr[i-1] >= arr[i] {
                j++
                arr[j] = arr[i]
            }
        }
        if i == j+1 {
            fmt.Println(cnt)
            break
        }
        arrLen = j + 1
    }

}

开发者ID:yaru22,项目名称:problem-solving,代码行数:25,代码来源:poisonous_plants.go

示例2: main

func main() {
    var x, y int

    fmt.Scanf("%d", &N)
    P = make(Ps, N)
    for i := 0; i < N; i++ {
        fmt.Scanf("%d %d", &x, &y)
        P[i] = NewPoint(i, x, y)
        T[i].l = NIL
        T[i].r = NIL
        T[i].p = NIL
    }
    np = 0
    root := makeKDTree(0, N, 0)

    log.Println(P)
    log.Println(T)
    var q int
    fmt.Scanf("%d", &q)
    var sx, tx, sy, ty int
    for i := 0; i < q; i++ {
        fmt.Scanf("%d %d %d %d", &sx, &tx, &sy, &ty)
        ans := lib.NewVector(N)
        log.Println(ans)
        find(root, sx, tx, sy, ty, 0, ans)
        for j := 0; j < ans.Size(); j++ {
            an := ans.V[j]
            ap := an.(Point)
            ap.disp()
        }
    }
}

开发者ID:iyoo14,项目名称:goalgo,代码行数:32,代码来源:kdtree.go

示例3: main

func main() {
    var T int
    fmt.Scanf("%d", &T)
    for t := 0; t < T; t++ {
        var N int
        fmt.Scanf("%d", &N)
        var no5, no3 = 0, 0
        for i := N / 3; i >= 0; i-- {
            if (N-3*i)%5 == 0 {
                no3 = i
                no5 = (N - 3*i) / 5
                break
            }
        }
        if no3 == 0 && no5 == 0 {
            fmt.Println("-1")
        } else {
            for i := 0; i < 3*no3; i++ {
                fmt.Print("5")
            }
            for i := 0; i < 5*no5; i++ {
                fmt.Print("3")
            }
            fmt.Println()
        }
    }
}

开发者ID:mohan08p,项目名称:Competitive_Programming,代码行数:27,代码来源:solution.go

示例4: SetChannelState

//SetChannelState sets the Channel inside the State
func SetChannelState(dg *discordgo.Session) {
    State.InsertMode = false

    guild := State.Guild
    d := color.New(color.FgYellow, color.Bold)
    d.Printf("Select a Channel:\n")
    for key, channel := range guild.Channels {
        if channel.Type == "text" {
            fmt.Printf("%d:%s\n", key, channel.Name)
        }
    }

    var response int
    fmt.Scanf("%d\n", &response)
    for guild.Channels[response].Type != "text" {
        Error := color.New(color.FgRed, color.Bold)
        Error.Printf("That's a voice channel, you know this is a CLI right?\n")
        d.Printf("Select a Channel:\n")
        fmt.Scanf("%d\n", &response)
    }

    State.Channel = guild.Channels[response]

    Clear()

    State.InsertMode = true
}

开发者ID:iopred,项目名称:discord-cli,代码行数:28,代码来源:init.go

示例5: main

func main() {
    var n int64
    var ans, m, t, i int64
    var a [200]int64
    fmt.Scanf("%v\n", &n)
    for i = 1; i <= n; i++ {
        fmt.Scanf("%v", &a[i])
    }

    t = 1
    ans = 1
    for a[t] == 0 {
        t = t + 1
        if t == n+2 {
            ans = 0
            break
        }
    }
    m = 0
    for i = t; i <= n; i++ {
        if a[i] == 1 {
            ans = ans * (m + 1)
            m = 0
        } else {
            m = m + 1
        }
    }
    fmt.Println(ans)
}

开发者ID:BanSheeGun,项目名称:Gun,代码行数:29,代码来源:B.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng