How to get the digits of a number without converting it to a string/ char array?

前端 未结 15 1340
既然无缘
既然无缘 2020-11-27 04:07

How do I get what the digits of a number are in C++ without converting it to strings or character arrays?

15条回答
  •  孤街浪徒
    2020-11-27 04:35

    First digit (least significant) = num % 10, second digit = floor(num/10)%10, 3rd digit = floor(num/100)%10. etc

提交回复
热议问题