Board logo

標題: for 迴圈 (二) [打印本頁]

作者: tonyh    時間: 2012-8-25 16:21     標題: for 迴圈 (二)

本帖最後由 tonyh 於 2012-8-25 16:30 編輯

顯示100以內的所有偶數
  1. public class ch15
  2. {
  3.      public static void main(String args[])
  4.      {
  5.            for(int i=2; i<=100; i+=2)  //i=i+2 或 i+=2
  6.            {
  7.                 System.out.println(i);
  8.            }
  9.      }
  10. }
複製代碼

作者: t2364705    時間: 2012-8-25 16:26

  1. public class ch15
  2. {
  3.     public static void main(String srgs[])
  4.     {
  5.         for(int i=2; i<=100; i+=2)
  6.         {
  7.             System.out.println(i);
  8.         }
  9.     }
  10. }
複製代碼

作者: 劉漢文    時間: 2012-8-25 16:27

  1. public class ch15
  2. {
  3.     public static void main(String srgs[])
  4.     {
  5.         for(int i=2; i<=100; i+=2)
  6.         {
  7.             System.out.println(i);
  8.         }
  9.     }
  10. }
複製代碼

作者: t3742238    時間: 2012-8-25 16:27

  1. import java.io.Console;
  2. public class ch13
  3. {
  4.    public static void main(String args[])
  5.    {
  6.        for(int i=2; i<=100; i+=2)
  7.        {
  8.          System.out.println(i);
  9.        }
  10.    }
  11. }
複製代碼

作者: 尤泓鈞    時間: 2012-8-25 16:28

  1. public class ch15
  2. {
  3.     public static void main(String srgs[])
  4.     {
  5.         for(int i=2; i<=100; i+=2)
  6.         {
  7.             System.out.println(i);
  8.         }
  9.     }
  10. }
複製代碼

作者: 粘靖瑜    時間: 2012-8-25 16:28

  1. public class ch15
  2. {
  3.     public static void main(String args[])
  4.     {
  5.           for(int i=2; i<=100; i+=2)
  6.           {
  7.                System.out.println(i);
  8.           }

  9.     }

  10. }
複製代碼

作者: 粘靖瑜    時間: 2012-8-25 16:29

public class ch15
{
    public static void main(String args[])
    {
          for(int i=2; i<=100; i+=2)
          {
               System.out.println(i);
          }

    }

}
作者: 蔡昀佑    時間: 2012-8-25 16:30

  1. public class ch15
  2. {
  3.     public static void main(String srgs[])
  4.     {
  5.         for(int i=2; i<=100; i+=2)
  6.         {
  7.             System.out.println(i);
  8.         }
  9.     }
  10. }
複製代碼

作者: 黃博鴻    時間: 2012-10-13 15:01

  1. public class ch15
  2. {
  3.   public static void main(String args[])
  4.   {
  5.     for(int i=2; i<=100; i+=2)
  6.     {
  7.     System.out.println(i);
  8.     }
  9.   }
  10. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2