#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* 本题要求编写程序,对于给定的整数N,求它的位数。*/
int main(int argc, char *argv[]) {
int n,count=0;
scanf("%d",&n);
if(n==0)
{
count=1;
}
else
{
count=0;
while(fabs(n)>0)
{
n=n/10;
count++;
}
}
printf("%d",count);
return 0;
}
统计一个整数的位数。本题要求编写程序,对于给定的整数N,求它的位数。输入在一行中给出一个绝对值不超过10 9 的整数N。在一行中输出N的位数。
最新推荐文章于 2024-05-01 10:20:06 发布