中文题目:
http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/chs/aevent9.mspx
英文解题: http://www.microsoft.com/technet/scriptcenter/funzone/games/solutions08/apssol09.mspx
我们需要将每个单词翻转输出, 但是单词顺序不能改变. 我首先设置$ofs为空, 接下来利用字符串对象的Split将输入按照空白字符分成多个字符串. 每个字符串就是要翻转的单词. 接下来通过管道, 传递给Foreach-Object. 通过生成逆序索引, 就可以生成反序的字符串. 最后连接起来. 利用了两次双引号的黏合...
$ofs
=
''
$paper = (Get - Content C :/ Scripts / Alice . txt) . split () | `
% { " $($_[($_.Length-1)..0]) " }
$ofs = ' '
" $paper "
$paper = (Get - Content C :/ Scripts / Alice . txt) . split () | `
% { " $($_[($_.Length-1)..0]) " }
$ofs = ' '
" $paper "