回答編集履歴
2
他の方の回答から reversed に変更
test
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
val tabemono = "tabemono"
|
46
46
|
|
47
|
-
val onomebat =
|
47
|
+
val onomebat = tabemono.reversed()
|
48
48
|
|
49
49
|
println(tabemono)
|
50
50
|
|
1
kotlin 追加
test
CHANGED
@@ -35,3 +35,27 @@
|
|
35
35
|
}
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
kotlin にしてみる...同じ (面白い方法が思いつきません orz)
|
40
|
+
|
41
|
+
```kotlin
|
42
|
+
|
43
|
+
fun main(args: Array<String>) {
|
44
|
+
|
45
|
+
val tabemono = "tabemono"
|
46
|
+
|
47
|
+
val onomebat = StringBuilder(tabemono).reverse().toString()
|
48
|
+
|
49
|
+
println(tabemono)
|
50
|
+
|
51
|
+
for(i in 1..tabemono.length-2) {
|
52
|
+
|
53
|
+
println(tabemono[i]+" ".repeat(tabemono.length-2)+onomebat[i])
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
println(onomebat)
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
```
|