@Java
Hello everyone, I'm Ziph!
Topic:
write a function that takes an integer, the output of the integer number is few
import java.util.Scanner;
public class TestInt {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个整数:");
long num = sc.nextLong();
getNumLength(num);
}
public static void getNumLength(long num) {
int count = 1;
while(num >= 10) {
count++;//如果满足条件就加1
num /= 10;
}
System.out.println(count);
}
}
The results:
If you have questions, please leave a message reply!