1.分析以下需求,并用代码实现:
(1)打印1到100之内的整数,但数字中包含9的要跳过
(2)每行输出5个满足条件的数,之间用空格分隔
(3)如:1 2 3 4 5
int count = 0;
for (int x = 1;x <= 100 ;x++ ) {
if (x % 10 != 9 && x/10%10 !=9) {
count ++;
if(count % 5==0) {
System.out.println(x);
}else {
System.out.print(x+" ");
}
}
} |
|