返回列表 發帖

while 迴圈 (一)

本帖最後由 tonyh 於 2016-4-29 19:48 編輯

利用 while 迴圈, 直列印出1~10.
  1. public class Ch23{
  2.     public static void main(String args[])
  3.     {
  4.         int i=1;
  5.         while(i<11)
  6.         {
  7.             System.out.println(i);
  8.             i++;
  9.         }
  10.     }
  11. }
複製代碼

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

TOP

  1. public class Ch23{
  2.     public static void main(String args[])
  3.     {
  4.         int i=1;
  5.         while(i<11)
  6.         {
  7.             System.out.println(i);
  8.             i++;
  9.         }
  10.     }
  11. }
複製代碼
http://fs-old.mis.kuas.edu.tw/~s1102137106/music/

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

  11.     }
  12. }
複製代碼

TOP

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

TOP

返回列表