/*打印1到100之内的整数,但数字中包含7的要跳过*/
class MyDemo_TiaoGuo7 {
public static void main(String[] args)
{ //以下是方法1
for(int i = 1; i<=100; i++){
int ge = i % 10 ;
int shi = i / 10 % 10 ;
if (ge ==7 || shi == 7 )
{
continue;
}
System.out.print(i+" " );
}
//以下是方法2
/*for (int x = 1;x <=100;x++){
int y = x/10;
if ( x-y*10 == 7|| x/10 == 7){
continue;
}
System.out.print(x+" " );
}*/
}
} |