问答详情
源自:4-15 编程练习

请问我这样些是不是太冗余了一点啊?

public class HelloWorld{
    public static void main(String[] args){
        int num = 999;        
        int count = 0;        
        if(num%1000000000==num&&num!=0){            
            for(int i=1; i<1000000000; i=i*10){                
                if(num%i==num){                    
                    break;                
                }                
            count++;            
            }            
            System.out.println("它是个"+count+"位的数!");        
        }else if(num==0){            
            System.out.println("它是个1位数的数!");        
        }else{            
            System.out.println("数字超出判断范围");
        }
    }
}


提问者:羁旅客li 2018-12-12 16:59

个回答

  • 弃S926
    2018-12-12 19:09:01

    严谨是码农必备素质,但是过分追求严谨却放弃简便,却是摘豆弃瓜之举。