/* 统计一个整数的位数 */#includeint main(void){ int count,number; count=0; printf("Enter a number:"); scanf_s("%d",&number); if(number<0)number=-number; do{ number=number/10; count++; }while(number!=0); printf("It contains %d digits.\n",count); return 0;}
本文共 361 字,大约阅读时间需要 1 分钟。
/* 统计一个整数的位数 */#includeint main(void){ int count,number; count=0; printf("Enter a number:"); scanf_s("%d",&number); if(number<0)number=-number; do{ number=number/10; count++; }while(number!=0); printf("It contains %d digits.\n",count); return 0;}
转载于:https://www.cnblogs.com/laurenliu1994/p/3352986.html