Given a text file <code>file.txt</code>, transpose its content.
You may assume that each row has the same number of columns and each field is separated by the <code>' '</code> character.
For example, if <code>file.txt</code> has the following content:
Output the following:
i = 1, s = [name]
i = 2, s = [name; age]
i = 1, s = [name alice; age]
i = 2, s = [name alice; age 21]
i = 1, s = [name alice ryan; age 21]
i = 2, s = [name alice ryan; age 21 30]
然後我們再将s中的各行列印出來即可,參見代碼如下:
解法一:
解法二: