프로그래밍/Boo
문자열 거꾸로 하기 with Boo
Scripter
2009. 4. 4. 19:16
▒ Boo 소스: testStringReverse.boo
/*
* Filename: testStringReverse.boo
*
* [참고] 이 파일은 UTF-8 인코딩으로 저장되어야 함.
*
* Compile: booc -utf8 testStringReverse.boo
* Execute: testStringReverse
*/
s = "Hello, world!"
s2 = "안녕하세요?"
#########################################
u = join(reversed(s), '') # 문자열 거꾸로 하기
u2 = join(reversed(s2), '') # 문자열 거꾸로 하기
print( "s = " + s )
print( " ---> " + "join(reversed(s), '') = " + u )
print( "s2 = " + s2 )
print( " ---> " + "join(reversed(s2), '') = " + u2 )
#########################################
# 출력 결과
# s = Hello, world!
# ---> join(reversed(s), '') = !dlrow ,olleH
# s2 = 안녕하세요?
# ---> join(reversed(s2), '') = ?요세하녕안
한글이 포함된 Boo 언어 소스코드는 반드시 UTF-8 인코딩으로 저장되어야 하고, booc 명령으로 컴파일할 때 -utf8 옵션을 주어야 한다.