// 获取x这个数的d位数上的数字 int getDigit(int x, int d) { int a[] = { 1, 1, 10 }; // 本实例中的最大数是十位数,所以只要到10就可以了 return ((x / a[d]) % 10); }