版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wowotuo/article/details/85019054
如果用Julia来写:
while true
input =readline();
println(replace(replace(replace(input,"吗"=>""),"?"=>"!"),"?"=>"!"))
end
如果你还要更省一点:
while true
println(replace(replace(replace(readline(),"吗"=>""),"?"=>"!"),"?"=>"!"))
end
但还不算优雅。不知还有没有其它简洁优雅的写法?
另外一种通用的写法:
while true
a = readline()
_dict=["吗"=>"","?"=>"!","?"=>"!"]
for element in _dict
global a =replace(a,element)
end
println(a)
end
但问题是:为什么要在循还中写一个global?