如何拆分int到它的数字? [英] howto split a int into its digits?
本文介绍了如何拆分int到它的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
给定号码12345:
5
是 12345% code>
4
是 12345/10%10
3
是 12345/100%10
/ code>是
12345/1000%10
1
是 12345/10000%10
我不会提供完整的代码,因为这肯定看起来像家庭作业,你得到的模式。
how can i split a int in c++ to its single numbers, e.g.: 23 to 2 and 3 ??
解决方案
Given the number 12345 :
5
is 12345 % 10
4
is 12345 / 10 % 10
3
is 12345 / 100 % 10
2
is 12345 / 1000 % 10
1
is 12345 / 10000 % 10
I won't provide a complete code as this surely looks like homework, but I'm sure you get the pattern.
这篇关于如何拆分int到它的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文