在 Julia 中反转字符串– reverse() 方法
reverse()
是 julia 中的内置函数,用于返回指定字符串的反转。
Syntax:
reverse(s::AbstractString)
Parameters:
- a::AbstractString: Specified string
Returns: It returns the reverse of the specified string.
示例 1:
# Julia program to illustrate
# the use of String reverse() method
# Getting the reverse of the specified string
println(reverse("GFG"))
println(reverse("gfg"))
println(reverse("Geeks"))
println(reverse("GeeksforGeeks"))
输出:
GFG
gfg
skeeG
skeeGrofskeeG
示例 2:
# Julia program to illustrate
# the use of String reverse() method
# Getting the reverse of the specified string
println(reverse("123"))
println(reverse("5"))
println(reverse("@#"))
println(reverse("^&*"))
输出:
321
5
#@
*&^