1.打印 1 到 100 之内的整数,但数字中包含9的或是9的倍数的要跳过
2.每行输出 5 个满足条件的数,之间用空格分隔
3.如:1 2 3 4 5
public class for1 {
public static void main (String[] args){
int count = 0;
for ( int i = 1; i <= 100 ;i++ ) {
if ( i % 10 == 9 || i % 9 == 0 || i / 10 % 10 == 9){
continue;
} else {
count++;
}
System.out.print(i + " ");
if (count % 5 == 0){
System.out.println();
}
}
}
}
这里的count计数器,定义在for循环外边,是因为count计数器要一直计数的,是要累积进行判断的。所以定义在for外边。