Identify the digits in a given number.

前端 未结 7 717
滥情空心
滥情空心 2020-12-07 03:41

I\'m new to programming, and I\'m stuck at a problem. I want my program to identify the separate digits in a given number, like if I input 4692, it should ident

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 04:06

    A perfect recursion problem to tackle if you're new to programming...

    4692/1000 = 4

    4692%1000 = 692

    692/100 = 6

    692%100 = 92

    92/10 = 9

    92%10 = 2

    You should get the idea for the loop you should use now, so that it works for any number. :)

提交回复
热议问题