2013-07-24 25 views

回答

2

下面的代碼給你一個想法,如何完成任務。

;        # Discard the input (golfscript takes 
           # input from STDIN) 

"#{File.read('input.txt')}" # Read contents of file into a string 
           # (see your previous question 
           # http://stackoverflow.com/q/17826704) 

[~]       # Evaluate the input into an array 

{2?}%       # Apply the operators `2?` to each element 
           # ("x 2 ?" simply calculates x^2) 

" "*       # Join the array elements with spaces 

           # By default the remaining items on the stack 
           # are printed when the program ends 

您可以找到每個運營商here的詳細信息。

+0

謝謝你,霍華德。 – Beatle

相關問題