出于某种原因,VSCode 以独占方式在调试控制台中运行,无论我是否在调试的情况下运行。因此,它不会识别用户输入,这是一个相对较大的问题。这可能是一个简单的解决方案,但希望有人能给我关于如何修复它的可靠建议。我会在下面粘贴我正在运行的实际代码:package mainimport ( "bufio" "fmt" "os" "strconv")func add(one int, two int) int { var three = one + two return three}func main() { var s []int one := 0 two := 1 input1 := bufio.NewScanner(os.Stdin) fmt.Println("How many places of the Fibbonaci sequence? ") input1.Scan() numplac := input1.Text() places, err := strconv.Atoi(numplac) _ = err for i := 0; i < places; { s = append(s, one) i++ if i < places { s = append(s, two) i++ one = add(one, two) two = add(one, two) } else { fmt.Printf("Finished at: %d \n", places) } } fmt.Println("Fibbonaci to", places, "places:") fmt.Println(s) for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } fmt.Println("Fibbonaci to", places, "places, reversed:") fmt.Println(s)}
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
- 1 回答
- 0 关注
- 102 浏览
添加回答
举报
0/150
提交
取消