俗話說,少了一根馬蹄釘,就失去了一個王國。
給定一個輸入陣列,產生對應的諺語。
例如,給定["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.
注意,輸入的陣列可能不同;你的解法應該要能處理任意長度與內容的陣列。 輸出的文字中,不該有任何一行是固定不變的字串;每一行都應該隨著給定的輸入而變化。
每個輸入清單都以 null 結尾的字串表示,而每個輸入的結尾都有一個換行字元。
例如:"nail\nshoe\nhorse\nrider\nmessage\nbattle\nkingdom\n"
| 暫存器 | 用途 | 型別 | 說明 |
|---|---|---|---|
$a0 |
輸入 | 位址 | 以 null 結尾的輸入字串,每個輸入後面都有一個換行 |
$a1 |
輸入/輸出 | 位址 | 以 null 結尾的輸出字串 |
$t0-9 |
暫時 | 任意 | 用於暫時存放資料 |