打印1到100中7的倍数
public class Print1_100_7beishu
{
public static void main(String[] args)
{
  int i=1;//i如此初始化,可以吗?
  while(i%7=0&&i<101)//本意是若可被7整除且小于101则打印i,怎么有错误
{
System.out.println(i);
i++;
}
    }
}
自己编写的初等小程序,请大家斧正

解决方案 »

  1.   

    while(i%7=0&&i<101)
    这个错拉,不能写成i%7=0应该为i%7==0才是
      

  2.   

    public class Print1_100_7beishu
    {
    public static void main(String[] args)
    {
     for(int i=1;i<101;i++){
     if(i%7 == 0){
     System.out.println(i);
     }
     }
        }
    }
      

  3.   

    public class Print1_100_7beishu
    {
    public static void main(String[] args)
    {
      int i=7;//i如此初始化,可以吗?
      while(i<101)//本意是若可被7整除且小于101则打印i,怎么有错误
    {
                          System.out.println(i);
    i+=7;
    }
        }
    }
      

  4.   

    复人:xuzhenqinandy(许振勤) ( ) 信誉:100 2007-03-07 16:47:55 得分:0
    while(i%7=0&&i<101)
    这个错拉,不能写成i%7=0应该为i%7==0才是加上后,编译没错误,但是没有输出东西啊?
    只显示按任意键继续
      

  5.   

    public class Print1_100_7beishu
    {
    public static void main(String[] args) {
      
      for(int i=1;i<=100;i++)
    {
                          if(i%7==0)
                          System.out.println(i);
    i+=7;
    }
        }
    }
      

  6.   

    效率比较高的,编译运行通过:public class Print1_100_7beishu {
    public static void main(String[] args)
    {
    int i = 7;
    while(i<=98){
    System.out.print(i + ",");
    i = i + 7; //每次都增加7
    }
        }
    }结果:7,14,21,28,35,42,49,56,63,70,77,84,91,98,
      

  7.   

    这个while的中的条件会成立么? 如果i初始化为1
    根本就不执行while里面的代码啊
    1%7 = 1  已经不成立, 这个根本就不会循环
    for(int i=0; i<101; i++){}
      

  8.   

    没写完
    for(int i=1; i<101; i++){
       if(i%7==0)System.out.println(i);
    }
    这不是最清晰的么?
      

  9.   

    public class Print1_100_7beishu
    {
    public static void main(String[] args)
    {
               for(int i=1;i<101;i++)
    {
    if(i%7==0)

    System.out.println(i);
    }    }
    }这个用if终于可以了
    但是用while连接i%7==0
    怎么不可以呢
      

  10.   

    不是有人说了吗,while里面的条件不成立
      

  11.   

    to ls:
    是啊,我的意思是
    int i=1;
    while(i%7==0&&i<101);
    如果要用到上面两句,应该怎么改呢