编辑代码

public class Demo1{
    public static void main(String[] args){
        int i,j;
        int count=0;
        for(i=1;i<=1000;i++){
            if(i==1||i==2){
                count++;
                System.out.print(i + "\t");
                continue;
            }
            for(j=2;j<i;j++){
                if(i%2==0){
                    break;
                }
                if(j==i-1){
                    count++;
                    System.out.print(i + "\t");
                }
                if(count==8){
                    count=0;
                    System.out.println();
                }
            }
        }
    }
}