public class HelloWorld {
//判断一个数的位数
// 两种情况:整数,小数
public static void main(String[] args) {
// TODO Auto-generated method stub
// double num=-999.999;
int num=-999;
int count=0;
// 如果是整数的话,判断
if(num*10%10==0){
count = num>0?(num+"").length():(num+"").length()-1;
}
// 如果是小数的话,判断
if(!(num*10%10==0)){
count = num>0?(num+"").length()-1:(num+"").length()-2;
}
System.out.println("它是个"+count+"位的数!《- . -》");
}
}
2025 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123