输出1—999中能被3整除且至少有两位数字是5的所有整数及其个数
程序员文章站
2022-07-15 12:23:16
...
public class test {
public static void main(String[] args) {
int[] arr = new int[999];
//定义常量
final short a = 3, b = 55;
int count = 0;
for (int i = 1; i < 999; i++) {
arr[i]=i;
if (i % a == 0 && (i % 100 == b || (i / 10) % 100 == b) )) {
System.out.print(i + "\t");
count++;
}
}
System.out.println(count);
![运行结果](https://img-blog.csdnimg.cn/20200928104330653.png#pic_center)