2014-03-25 36 views
0

我想讓用戶給我一個可變數量的字符串(作爲virables)。 例如:如何在pascal中打印可變數量的參數?

begin cout('Hello')。 ('')。('world') 結束。

會打印出「Hello World」的 我知道我可以讓他輸入一個字符串,但我想這個代碼工作... 我想記錄將有助於螺母我不知道如何 謝謝

+0

根據方言,在手冊中搜索「array of const」 –

回答

0

林不知道你寫的代碼示例是什麼...但我盡力幫助你。

Program test; 
uses crt; 

var string1,string2,string3:string; 


begin 
write("Write to first string : "); readln(string1); 
write("Write to second string: "); readln(string2); 
write("Write to third string : "); readln(string3); 

String2:= string1 +" "+ string3; // it will add first with third string to one with one space 

String3:= string2 +" "+ string1;// also 2.+ 1. 
clrscr; //clearscreen (in CRT) 
writeln("1. = 1."); 
writeln("2. = 1. + 3."); 
writeln("3. = 2. + 1."); 
writeln; 
writeln(string1); 
writelm(string2); 
writeln(string3); 

我還沒有測試這個(我現在寫它你)我想你會讀它,並學會如何上癮或如何做簡單的處理字符串。