俗話說,少了一根馬蹄釘,就失去了一個王國。
給定一個輸入陣列,產生對應的諺語。
例如,給定["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.
注意,輸入的陣列可能不同;你的解法應該要能處理任意長度與內容的陣列。 輸出的文字中,不該有任何一行是固定不變的字串;每一行都應該隨著給定的輸入而變化。
每一組輸入都以字串表示,而每個輸入的結尾都有一個換行字元。
例如:"nail\nshoe\nhorse\nrider\nmessage\nbattle\nkingdom\n"
每一行輸出都應該以換行字元\n結尾。
線性記憶體的第 128 到 383 個位元組保留給輸入字串。