所以我寫了這個小的 go 程序,它向圖靈機提供指令,并從中打印選定的單元格: package mainimport "fmt"import s "strings"func main() { fmt.Println(processturing("> > > + + + . ."));}func processturing(arguments string) string{ result := "" dial := 0 cells := make([]int, 30000) commands := splitstr(arguments, " ") for i := 0;i<len(commands);i++ { switch commands[i] { case ">": dial += 1 case "<": dial -= 1 case "+": cells[dial] += 1 case "-": cells[dial] -= 1 case ".": result += string(cells[dial]) + " " } } return result}//splits strings be a delimeterfunc splitstr(input, delim string) []string{ return s.Split(input, delim)}問題是,當它運行時,控制臺不顯示任何內(nèi)容。它只是什么都不顯示。我如何使這個對fmt.println我的函數(shù)的結(jié)果字符串起作用?
- 1 回答
- 0 關注
- 230 瀏覽
添加回答
舉報
0/150
提交
取消