1 PackageCom.xt.homework.tools;2 /**3 * 4 * 7. Topic5 * Vampire numbers are digits with even numbers, which can be multiplied by a pair of numbers,6 * The number of digits is half the number of digits and consists of the digits that make up the original number,7 * The number ending with two 0 is not a vampire number. 8 * For example: 1260 = * 1827 = * 2187= * Bayi9 * Ask all four vampire numbersTen * One * @authorTin Yiu Phase two A * Yang Bulong - */ - Public classHomeWork07 { the Public Static voidMain (string[] args) { - for(inti = 1000; I <= 9999;i++) - { - intA = (int) (i/1000);//thousand numbers + intB = (int) ((i-a*1000)/100);//Hundred Numbers - intc = (int) ((I-(int) (i/100)) (*100)/10);//10-digit number + intD = (int) (I-(int) (I/10)) *10);// digit Digit A if(c==0&&d==0) at Continue; - if((10*a+d) * (10*c+b) ==i| | (10*b+a) * (10*c+d) ==i| | -(10*b+a) * (10*d+c) ==i| | (10*b+d) * (10*c+a) ==i| | -(10*c+a) * (10*d+b) ==i| | (10*c+b) * (10*d+a) = =i) { - System.out.println (i); - } in } - } to}
Really can not think of a good way, there is a big God there is a simple way please post to the comment area Thank you!
"Java" asks all four vampire numbers