数位数
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
给定一个正整数 n ,请你求出它的位数。
Input
单组输入,输入一个整数 n 。(1<= n <= 2147483647)
Output
输出一行,包含一个整数,即为 n 的位数。
Sample Input
1234567
Sample Output
7
代码
#include<stdio.h>
int main()
{
int a,n=0;
scanf("%d",&a);
while(a)
{
n++;
a=a/10;
}
printf("%d",n);
return 0;
}