4.编写程序,打印1到100之内的整数,但数字中包含7的要跳过

class Test5 {
public static void main(String[] args) {
//字符串实现
for (int i = 1; i < 100; i++) {
if ((i + "").indexOf("7") < 0) {
System.out.print(i + "\t");
}
}
//非字符串实现
for (int i = 1; i < 100; i++) {
if (i%10!=7 &&(i/10)%10!=7){
System.out.print(i + "\t");
}
}
}
}

猜你喜欢

转载自www.cnblogs.com/a709898670/p/9321440.html