Board logo

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

作者: tonyh    時間: 2012-8-25 15:41     標題: for 迴圈

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

在螢幕上顯示數字從1到10, 直向排列.
  1. public class ch14
  2. {
  3.      public static void main(String args[])
  4.      {
  5.            for(int i=1; i<=10; i++)  //初始值; 終止值; 遞增或遞減的條件
  6.            {
  7.                 System.out.println(i);
  8.            }
  9.      }
  10. }
複製代碼

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

本帖最後由 劉漢文 於 2012-8-25 16:12 編輯
  1. import java.io.Console;
  2. public class ch13
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         for(int i=1; i<=10; i++)
  7.         {
  8.           System.out.println(i);
  9.         }
  10.     }
複製代碼

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

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

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

本帖最後由 t3742238 於 2012-8-25 16:16 編輯
  1. import java.io.Console;
  2. public class ch13
  3. {
  4.    public static void main(String args[])
  5.    {
  6.        for(int i=1; i<=10; i++)
  7.        {
  8.          System.out.priln(i);
  9.        }
  10.    }
  11. }
複製代碼

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

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

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

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

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

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

  9.     }

  10. }
複製代碼

作者: 黃博鴻    時間: 2012-10-13 14:58

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





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