开发者

why they read one more

开发者 https://www.devze.com 2022-12-07 20:23 出处:网络
package main import ( "bufio" "fmt" "os" "strings" ) func main() { stdin := bufio.NewReader(os.Stdin)
package main

import (
    "bufio"
    "fmt"
    "os"
    "strings"
)

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    var result string
    var fname []string

    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        tmp := ""
        stdin.ReadString('\n')
        fmt.Scan(&tmp)
        fmt.Println(tmp)
        fname = append(fname, tmp)
        fmt.Println(fname)

    }
    redoc := make([]string, len(fname[0]))
    for _, i := range fname {
        for ind, j := range i {
            redoc[ind] = redoc[ind] + string(j)
  开发者_高级运维      }
    }

    for _, i := range redoc {
        if strings.Count(i, string(i[0])) == n {
            result = result + string(i[0])
        } else {
            result = result + "?"
        }
    }
    fmt.Print(result)
}

i just type qwer five time but "5" is input first on fname

5 in 'n' and i clear buffer but 5 is steel there i want input in fname [qwer qwer qweg qwef qwed]

but work [5 qwer qwer qweg qwef]

0

精彩评论

暂无评论...
验证码 换一张
取 消