//判断用户输入的数字为几位数#include<stdio.h> int my_function(int n); //判断几位数函数int my_function(int n)
{int count = 0;while(n != 0){n = n / 10;count++;}return count;
}int main()
{int n , count , t;printf("请您输入一个整数 : ");scanf("%d",&n);t = n;count = my_function(n);printf("%d是%d位数 " , t , count);return 0;
}
运行结果如下: