1 2
| go get github.com/EndlessCheng/codeforces-go
|
用最基本的fmt.Scanln()当然可以,这里提供一种解决方法,用bufio处理,将输入输出转换成go_test。
Sol.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| package main
import ( "bufio" "fmt" "io" "os" )
func Sol(_r io.Reader, _w io.Writer) { in := bufio.NewReader(_r) out := bufio.NewWriter(_w) defer out.Flush()
}
func main() { Sol(os.Stdin, os.Stdout) }
|
Sol_test.go
1 2
| 输入(inputCopy) 输出(outputCopy)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| package main
import ( "testing" "github.com/EndlessCheng/codeforces-go/main/testutil" )
func TestSol(t *testing.T) { rawText := ` inputCopy
outputCopy
` testutil.AssertEqualCase(t, rawText, 0, Sol) }
|
本文作者:jujimeizuo
本文地址: https://blog.jujimeizuo.cn/2022/05/12/go-for-codeforces/
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0 协议。转载请注明出处!