查找数字的特定数字 [英] Finding a Specific Digit of a Number
本文介绍了查找数字的特定数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到任意长度的整数的 n
th数字。我要将整数转换为字符串并使用索引n处的字符...
I'm trying to find the n
th digit of an integer of an arbitrary length. I was going to convert the integer to a string and use the character at index n...
char Digit = itoa(Number).at (n);
...但是我意识到 itoa
标准。有没有其他方法可以做到这一点?
...But then I realized the itoa
function isn't standard. Is there any other way to do this?
推荐答案
(number / intPower(10,n)) %10
只需定义函数 intPower
。
这篇关于查找数字的特定数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文