2011-03-25 67 views
2

我怎樣才能使在該代碼在輸入命令的對話框中的文本是這樣「輸入1個元件」,「輸入2元素」 ....與輸入輸入數據[]在數學

For[k = 1, k ≤ n, k++, 
    br = Input["Enter the ",i,"element"]; 
    AppendTo[x, br]; 
] 

回答

2

確保您的變量匹配。 :-)

您可以使用來構建文本。

x = {}; 
n = 3; 
For[k = 1, k <= n, k++, 
br = Input[Row[{"Enter the ", k, " element"}]]; 
AppendTo[x, br]; 
] 

(你也可以使用StringJoin["Enter the ", ToString[k], " element"],但我喜歡更好。)

1

按照輸入[]幫助:

The prompt given can be text, graphics or any expression. 

那麼,什麼將適合的輸入提示!

只是作爲一個例子(注意顯式循環也沒必要):

x = Input[ 
    Panel[[email protected]{{Row[{"Enter the element number ", #}]}, 
        {PolyhedronData["Platonic", {"Image"}][[Mod[#, 5] + 1]]}}] 
     ] & /@ Range[1, 5] 

將顯示之類的東西:

enter image description here