#include<stdio.h>
#include<math.h>
// 求x用10进制表示时的数位长度 
int len(int x){
    if(x<10) return 1;
    return len(x/10)+1;
}
    
// 取x的第k位数字
int f(int x, int k){
    if(len(x)-k==0) return x%10;
    return f(x / pow(10, len(x) - k), k);  
}
    
int main()
{
    int x, k;
    printf("请输入数字和查找位置:");
    scanf("%d %d", &x, &k); 
    printf("位置 %d 上的数字为 :%d\n", k, f(x,3));
    return 0;
}

 

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2021-11-05
猜你喜欢
  • 2021-05-19
  • 2022-12-23
  • 2021-12-21
  • 2021-07-03
  • 2021-10-31
  • 2021-07-30
相关资源
相似解决方案