pascal程式有些不懂!!! |
答題得分者是:flyup
|
mahonchi
一般會員 發表:1 回覆:1 積分:0 註冊:2003-02-21 發送簡訊給我 |
我所寫的程式是關於要輸出以下的程序﹕
Please enter starting position? 0
Error: Zero is disallowed.
Please enter starting position? 3
How many terms? 0
Error: Zero is disallowed.
How many terms? 5
The F-series will be 2, 3, 5, 8 and 13.
這些數字是關於﹕1, 1, 2, 3, 5, 8, 13 ,,,
即是除第一及第二個外,其他的數項是前兩個數列的總和。
??????????????????????????
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
|
mahonchi
一般會員 發表:1 回覆:1 積分:0 註冊:2003-02-21 發送簡訊給我 |
我的問題是不懂如何用Pascal寫出以下輸出的結果。 程序描述:
用 Pascal 編寫一個程序去顯示F數字列的其中一段落。
F數字列: 1, 1, 2, 3, 5, 8, 13 ,,,
(除第一及第二個外,其他的數項是前兩個數列的總和) 程序輸出樣本:
Please enter starting position? 0
Error: Zero is disallowed.
Please enter starting position? 3
How many terms? 0
Error: Zero is disallowed.
How many terms? 5
The F-series will be 2, 3, 5, 8 and 13. 程序架構:
program Generate_Fseries;
var prev1, prev2, current: integer; {之前兩個及現在的數項}
start, num : number; {開始位置及數項數目}
begin
...
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
program Project1; uses
System; {$R *.RES} var
prev1, prev2, current: integer; {之前兩個及現在的數項}
start, num : number; {開始位置及數項數目}
s:string;
a:boolean;
begin prev1 :=1;
prev2 :=1;
current:=2;
a:=false; while true do
begin Write('Please enter starting position?');
Readln(s); try
start=strtoint(s);
a:=true;
except
a:=false;
Write('請輸入數字');
end; if a then
begin
if start<3 then Write('請輸入大於3的數字')
else
begin
Write('How many terms?');
Readln(s);
//接下來 請自己寫 end; end; end; end.
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |