出于某種原因,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 關注
- 140 瀏覽
添加回答
舉報
0/150
提交
取消