求整数的第k位的值 | 幂运算
//判断有多少位
static int len(int x){
if(x<10) return 1;
return len(x/10)+1;
}
// 取x的第k位数字
static int f(int x, int k){
if(len(x)-k==0) return x%10;
//return ______________________; //填空
return (int) (x%Math.pow(10,len(x)-k+1)/Math.pow(10,len(x)-k));
}
public static void main(String[] args)
{
int x = 23513;
//System.out.println(len(x));
System.out.println(f(x, 5));
}