日期:2014-05-20 浏览次数:20791 次
for(int i = 1; i>0; i++){
String str = i+"";
String x = str.substring(str.length()-1);
if(x.equals("6")){
int y = Integer.parseInt(6+str.substring(0,str.length()-1));
if(i*4==y){
System.out.println(i);
break;
}
}
}
------解决方案--------------------
public static void get() {
int i = 106;
while (true) {
// 如果找到了,则输出,跳出循环
if (i * 4 == change(i) * 6 + i / 10) {
System.out.println(i);
break;
}
i+=10;
}
}
// 寻找数的数量级
public static int change(int d) {
int result = 1;
int temp = d;
while ((temp /= 10) != 0) {
result *= 10;
}
return result;
}
最传统的方法,没有介入其他函数。