線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1132
推到 Plurk!
推到 Facebook!

compiler MaxMin語法錯誤

答題得分者是:老大仔
delphi_95
一般會員


發表:1
回覆:2
積分:0
註冊:2011-09-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-12-04 04:49:29 IP:173.183.xxx.xxx 訂閱
學校作業

program VertexofaQuadratic;
{$APPTYPE CONSOLE}
uses
SysUtils;
(******************************************************************************)
var
A : Integer;
B : Integer;
C : Integer;
XNumber : Real;
YNumber : Real;
(******************************************************************************)

procedure Vertex;

begin
Write(' Enter A Number: ');
ReadLn (A);
WriteLn;
Write(' Enter B Number: ');
ReadLn (B);
WriteLn;
Write(' Enter C Number: ');
ReadLn (C);
WriteLn;
MaxMin(A,B,C,XNumber,YNumber);
WriteLn('The axis of symmetry for the quadratic is ' , XNumber:1:2) ;
if A < 0 then
begin WriteLn('The quadratic is a maximum');
WriteLn;
end
else WriteLn('The quadratic is a minimum') ;
end;

(******************************************************************************)
procedure MaxMin(a:Integer;b:Integer;c:Integer;var XValue,YValue:Real);

begin
XValue:= -b/(2*a);
YValue:= (-sqr(b)/(4*a)) c;
WriteLn('The vertex is (' ,XValue:1:2, ',', YValue:1:2, ')');
end;

(************************* Main Program ***************************************)
procedure Main;
var
Choice : char;
begin

Repeat

WriteLn('Do you want to run the Vertex of a Quadratic "Y" or "y"');
WriteLn('Exit press "E" or "e" ');
ReadLn(Choice);
WriteLn;
while (Choice <> 'Y') and (Choice <> 'y')
and (Choice <> 'E') and (Choice <> 'e') do
begin
WriteLn('Please re-enter "Y" or "E"');
ReadLn (Choice);
WriteLn;
end;
if (Choice = 'Y') or (Choice = 'y')
then Vertex;
until (Choice = 'E') or (Choice = 'e');
end;

begin
Main;
end.


P.D.
版主


發表:603
回覆:4038
積分:3874
註冊:2006-10-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2011-12-04 23:35:06 IP:118.160.xxx.xxx 未訂閱
好歹也說一下跑下來的錯誤訊息是什麼吧?
delphi_95
一般會員


發表:1
回覆:2
積分:0
註冊:2011-09-21

發送簡訊給我
#3 引用回覆 回覆 發表時間:2011-12-05 06:43:17 IP:173.183.xxx.xxx 訂閱
抱歉,沒有寫出錯誤訊息!!!

Undeclared identifier 'MaxMin' at line 27(27:2)
老大仔
尊榮會員


發表:78
回覆:837
積分:1088
註冊:2006-07-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2011-12-05 08:04:32 IP:59.120.xxx.xxx 未訂閱
請把 program VertexofaQuadratic; 的上面即可


===================引 用 delphi_95 文 章===================
學校作業

MaxMin(A,B,C,XNumber,YNumber);
WriteLn('The axis of symmetry for the quadratic is ' , XNumber:1:2) ;
if A < 0 then
begin WriteLn('The quadratic is a maximum');
WriteLn;
end
else WriteLn('The quadratic is a minimum') ;
end;

(******************************************************************************)
procedure MaxMin(a:Integer;b:Integer;c:Integer;var XValue,YValue:Real);

begin
XValue:= -b/(2*a);
YValue:= (-sqr(b)/(4*a)) c;
WriteLn('The vertex is (' ,XValue:1:2, ',', YValue:1:2, ')');
end;


(************************* Main Program ***************************************)
procedure Main;
var
Choice : char;
begin

Repeat

WriteLn('Do you want to run the Vertex of a Quadratic "Y" or "y"');
WriteLn('Exit press "E" or "e" ');
ReadLn(Choice);
WriteLn;
while (Choice <> 'Y') and (Choice <> 'y')
and (Choice <> 'E') and (Choice <> 'e') do
begin
WriteLn('Please re-enter "Y" or "E"');
ReadLn (Choice);
WriteLn;
end;
if (Choice = 'Y') or (Choice = 'y')
then Vertex;
until (Choice = 'E') or (Choice = 'e');
end;

begin
Main;
end.


編輯記錄
老大仔 重新編輯於 2011-12-04 17:05:11, 註解 無‧
delphi_95
一般會員


發表:1
回覆:2
積分:0
註冊:2011-09-21

發送簡訊給我
#5 引用回覆 回覆 發表時間:2011-12-05 13:53:16 IP:173.183.xxx.xxx 訂閱
根基不夠的我
請教
為什麼要移到program上面?


老大仔
尊榮會員


發表:78
回覆:837
積分:1088
註冊:2006-07-06

發送簡訊給我
#6 引用回覆 回覆 發表時間:2011-12-05 16:45:24 IP:59.120.xxx.xxx 未訂閱
因為 program VertexofaQuadratic 中有呼叫到 procedure MaxMin;
所以 程式會"往回找"
但因為找不到procedure MaxMin
所以會出現 "Undeclared identifier 'MaxMin' at line 27(27:2)"
程式不知道從何呼叫它~

請先翻書&多多爬文~
有很多基本的東西書本都會教的~^^


===================引 用 delphi_95 文 章===================
根基不夠的我
請教
為什麼要移到program上面?


系統時間:2024-04-27 6:59:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!