諺語

諺語

簡單

說明

俗話說,少了一根馬蹄鐵釘,就失去了一個王國。

給定一個輸入陣列,產生對應的諺語。例如,給定陣列["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"],你要輸出這首諺語韻文的完整內容:

For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a nail.

請注意,輸入的陣列可能不同;你的解法應該能處理任意長度與內容的陣列。輸出的每一行都不應該是固定不變的字串,全都應該隨著給定的輸入而變化。


出處

Wikipedia連結會在新視窗或分頁中開啟
透過 GitHub 編輯 連結會在新視窗或分頁中開啟
Delphi Pascal Exercism

準備好開始 諺語 了嗎?

註冊 Exercism,透過 76 個練習 和真人引導來學習並精通 Delphi Pascal,全部免費。