读数,分辨几位数
1.计算机模仿人的行为是朴素的方法
2.充分利用计算机本身的特点计算出来的算法则是比较高档的算法
public class Hello {
public static void main(String[] args) {
// 初始化
Scanner in = new Scanner(System.in);
int number = in.nextInt();
int count = 0;
while ( number > 0 )
{
number = number / 10;
count = count + 1;
}
System.out.println(count);
}
}
1.循环停止条件
while ( number > 0 )
2.if条件要循环就用while
if ( number > 0 )