- 使用到的语法,"/" 整除运算符
1/10 = 0;
10/10 = 1;
15/10 = 1;
20/10 = 2;
- 方法如下:
int getDigit(int x)
{
int count = 0;
while(x != 0)
{
x /= 10;
count++;
}
return count;
}
1/10 = 0;
10/10 = 1;
15/10 = 1;
20/10 = 2;
int getDigit(int x)
{
int count = 0;
while(x != 0)
{
x /= 10;
count++;
}
return count;
}