2011-01-27 26 views
0

我的代碼在下面引發異常。爲什麼?在pascal程序中非法表達

program Masquerade(input, output); 
    Begin 
var amount, count, money : integer; 
writeln ('Welcome to the Wonder True Masquerade Band'); 
writeln ('Would you like to proceed? Yes/No'); 

var choice : String; 
readln (choice); 
End. 

拋出錯誤:fatal: syntax error ";" expected but "identifier AMOUNT" found

應該在哪裏分號去了?

回答

5

var之後放begin

我沒有用帕斯卡多年,沒有任何的編譯器進行測試,但它應該是這樣的:

program Masquerade(input, output); 
var 
    amount, count, money : integer; 
begin 
    writeln ('Welcome to the Wonder True Masquerade Band'); 
... 
+2

沒錯。您不能在pascal中的代碼塊內聲明變量。 – CodesInChaos 2011-01-27 19:50:51