Hi 各位前輩
我目前是透過以下方式去畫多條線
Array: test[20](0);
Vars: for_index(0);
For for_index = 1 to 20
Begin
test[for_index] = for_index+for_index;
End;
For for_index = 1 to 20
Begin
IF test[for_index] > 10 then
Begin
IF for_index = 1 then plot(1, test[for_index], "第1條線");
IF for_index = 2 then plot(2, test[for_index], "第2條線");
.
.
.
IF for_index = 20 then plot(20, test[for_index], "第20條線");
End;
End;
但是下方畫線的部分有點繁瑣,我希望可以透過 For 迴圈的特性簡化成以下方式
Array: test[20](0);
Vars: for_index(0);
For for_index = 1 to 20
Begin
test[for_index] = for_index+for_index;
End;
For for_index = 1 to 20
Begin
IF test[for_index] > 10 then
Begin
IF for_index = 1 then plot(for_index, test[for_index], "第"for_index"條線");
End;
End;
但是我目前遇到兩個問題
第一個問題
如果我將 plot(1, tes.... 的數字改成變數。例如 plot(for_index, tes.... 。 編譯會發生錯誤,錯誤訊息為「函數 plot: 第1個參數必須介於 1 到 999。」,沒辦法將數字用變數代替,請問有相關解法嗎 ?
第二個問題
是字串的相連,像是 ... est[for_index], "第"for_index"條線")... 我想要將 「"第"for_index"條線"」相連起來,假設 for_index 現在的值是19 那該跟線就會被命名稱 「第19條線」,請問有相關解法嗎?
謝謝
3 評論