import java.util.Scanner;
public class Test5 {
public static void main(String[] args) {
//输入一个数打印1到这个数中间各个位数相加为5的数
int res = 0;
int count = 0;
int c = 0;
Scanner sc = new Scanner(System.in);
int j = sc.nextInt();
for (int i = 5; i <= j; i++) {
for (int k = 1; k <= i;) {
int l0 = i / k % 10;
res += (l0 * k);
count += l0;
k *= 10;
}
if (count == 5) {
c++;
System.out.println(res);
}
count = 0;
res = 0;
}
System.out.println("满足条件的共有" + c + "个");
}
}
鸡兔同笼和百元百鸡问题
public class Test23 {
public static void main(String[] args) {
// 鸡兔同笼 i对应鸡数
// int i = 0;
// while (i <= 80) {
// if (i * 2 + (80 - i) * 4 == 208) {
// System.out.println("鸡有" + i + "只,兔有" + (80 - i) + "只");
// }
// i++;
// }
//百元百鸡
for (int i = 0; i <= 20; i++) {
for (int j = 0; j <= 33; j++) {
if ((100 - i - j) % 3 == 0 && 5 * i + (100 - i - j) / 3 + 3 * j == 100) {
System.out.println("鸡翁有" + i + "只,鸡母有" + j + "只,鸡雏有" + (100 - i - j) + "只");
}
}
}
}
}
打印100~205间的质数
public class Test2 {
public static void main(String[] args) {
int k;
int i;
int count = 0;
for (k = 101; k <= 205; k++) {
for (i = 2; i <= (int) Math.sqrt(k); i++) {
if (k % i == 0) {
break;
}
}
if (i > (int) Math.sqrt(k)) {
System.out.print(k + "t");
count++;
if (count != 0 && count % 6 == 0) {
System.out.println();
}
}
}
System.out.println("n" + count + "个质数");
}
}



