题目:809*x=800*x+9*x+1(去掉最后的1有解)
其中x代表的两位数,8*x的结果为两位数,9*x的结果为3位数.求x代表的两位数,及809*x后的结果(两种方法实现)
public class _042PrintResult { public static void main(String[] args) {
printResult();
printResult2();
} private static void printResult2() {
boolean flag = false;
int total_01 = 0, total_02 = 0, i = 10;
for (; i < 100; i++) {
total_01 = 809 * i;
total_02 = 800 * i + 9 * i + 1;
if ((8 * i) / 10 > 0 && (8 * i) / 10 < 10) { // 8*??的结果为两位数
if ((9 * i) / 100 > 0 && (9 * i) / 100 < 10) { // 9*??的结果为三位数
if (total_01 == total_02) {
flag = true;
}
}
}
} if (flag) {
System.out.println("该两位数为:" + i);
System.out.println("809*i = " + 809 * i);
} else {
System.out.println("无符合要求的数");
}
} private static void printResult() {
int a = 809, b, i;
for (i = 10; i < 13; i++) {
b = i * a;
if (8 * i < 100 && 9 * i >= 100) {
System.out.println("809*" + i + "=" + "800*" + i + "+" + "9*"
+ i + "=" + b);
}
}
} }