输入一句英文,把每个单词里的字母倒序。单词在句子中的位置不变。
androlua吧
全部回复
仅看楼主
level 9
nirenr 楼主
s="hello word."
l=#s
t={}
table.insert(t,{})
for n=1,l do
local a=s:sub(n,n)
if a<"A" or a>"z" then
table.insert(t[#t],a)
table.insert(t,{})
else
table.insert(t[#t],1,a)
end
end
for k,v in ipairs(t) do
t[k]=table.concat(v)
end
print(table.concat(t))
2015年01月02日 14点01分 1
level 9
nirenr 楼主
s="hello world"
r=string.gsub(s,"(%w*)",string.reverse)
print(r)
2015年01月03日 01点01分 2
1