}
}
}
【程序42】 题目:809*??=800*??+9*??+1。其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数。求??代表的两位数,及809*??后的结果。
(本题为无解,去掉1有解)
public class Demo42 {
public static void main(String[] args) {
for (int i = 10; i < 100; i++) {
if (809 * i == (800 * i + 9 * i + 1) && 8 * i >= 10 && 8 * i < 100
&& 9 * i >= 100 && 9 * i < 1000) {
System.out.println("?? =" + i);
System.out.println("809*??="+ 809 * i);
System.exit(0);
}
}
}
}
【程序43】 题目:求0—7所能组成的奇数个数。
暴力算法:
public class Demo43 {
public static boolean isJiShu(int n) {
if (n % 2 != 0) {
return true;
} else {
return false;
}
}
public static boolean fun(char c) {
if (c >= '0' && c <= '7'
) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
int count = 0;
String s;
for (int i = 0; i < 10
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新高等教育JAVA经典算法50题(24)全文阅读和word下载服务。