1 #include<stdio.h>
2 int getbit(long num)
3 {
4 if(num ==0 )
5 return 0;
6 else if(num <0)
7 num =-num ;
8 return getbit(num/10)+1;
9
10 }
11 int main()
12 {
13 long num;
14 int bit;
15 printf("请输入一个数: ");
16 scanf("%d",&num);
17 bit=getbit(num);
18 printf("%d的位数是%d ",num,bit);
19 return 0;
20 }