Int x 를 문자열로 바꿔서 자리수 접근 하기

shin_stealer·약 13시간 전
0
  • x: Int

  • x.toString().toCharArray()

여기서 각 자리 수의 합을 구하려면

  • x.toString().toCharArray()
    .map{it.toString().toInt()}
    .sum()
  • Char 에서 toInt() 는 없음. String 에서 toInt() 는 있음.
profile
I am a Blacksmith.

0개의 댓글