Board logo

標題: 函式的建立與執行 (四) [打印本頁]

作者: tonyh    時間: 2013-1-5 16:41     標題: 函式的建立與執行 (四)

本帖最後由 tonyh 於 2013-1-5 16:52 編輯

自訂一個專門列印九九乘法表的函式, 並在主函式中執行.
  1. public class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }
  7.    
  8.     public static void print99()
  9.     {
  10.         for(int i=1; i<=9; i++)
  11.         {
  12.             for(int j=1; j<=9; j++)
  13.             {
  14.                 System.out.print(i+"x"+j+"="+(i*j)+"\t");
  15.             }
  16.             System.out.println();
  17.         }
  18.     }
  19. }
複製代碼

作者: lon    時間: 2013-1-5 16:44

  1. public class ch52{
  2.   public static void main(String args[]){
  3.     print99();
  4.     }
  5.   public static void print99(){
  6.     for(int i=1;i<10;i++){
  7.       for(int j=1;j<10;j++){
  8.         System.out.print(i+"x"+j+"="+(i*j)+"\t");
  9.         }
  10.         System.out.println();
  11.       }
  12.     }
  13. }
複製代碼

作者: 黃博鴻    時間: 2013-1-5 16:46

  1. public class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }
  7.     public static void print99()
  8.     {
  9.            for(int i=1; i<=9; i++)
  10.            {
  11.                for(int j=1; j<=9; j++)
  12.                {
  13.                  System.out.print(i+"x"+j+"="+(i*j)+"\t");
  14.                }
  15.                System.out.println();
  16.            }
  17.     }

  18. }
複製代碼

作者: t2364705    時間: 2013-1-5 16:47

  1. public class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }
  7.     public static void print99()
  8.     {
  9.            for(int i=1; i<=9; i++)
  10.            {
  11.                for(int j=1; j<=9; j++)
  12.                {
  13.                  System.out.print(i+"x"+j+"="+(i*j)+"\t");
  14.                }
  15.                System.out.println();
  16.            }
  17.     }

  18. }
複製代碼

作者: t3742238    時間: 2013-1-5 16:47

本帖最後由 t3742238 於 2013-1-5 16:49 編輯
  1. public class ch51
  2. {
  3.     public static void main(String args[])
  4.     {
  5.          print99();
  6.     }

  7.     public static float print99()
  8.     {
  9.          for(int i=1;i<=9;i++)
  10.          {
  11.            for(int j=1;j<=9;j++)
  12.            {
  13.            System.out.print(i+"x"+j+"="+(i*j)+"\t");
  14.            }
  15.          }System.out.println;
  16.     }

  17. }
複製代碼

作者: 尤泓鈞    時間: 2013-1-5 16:49

  1. public class ch51
  2. {
  3.     public static void main(String args[])
  4.     {
  5.          print99();
  6.     }

  7.     public static float print99()
  8.     {
  9.          for(int i=1;i<=9;i++)
  10.          {
  11.            for(int j=1;j<=9;j++)
  12.            {
  13.            System.out.print(i+"x"+j+"="+(i*j)+"\t");
  14.            }
  15.          }System.out.println;
  16.     }

  17. }
複製代碼

作者: 蔡昀佑    時間: 2013-1-5 16:54

  1. public class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }
  7.    
  8.     public static void print99()
  9.     {
  10.         for(int i=1; i<=9; i++)
  11.         {
  12.             for(int j=1; j<=9; j++)
  13.             {
  14.                 System.out.print(i+"x"+j+"="+(i*j)+"\t");
  15.             }
  16.             System.out.println();
  17.         }
  18.     }
  19. }
複製代碼

作者: 劉漢文    時間: 2013-1-5 16:54

  1. public class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }
  7.    
  8.     public static void print99()
  9.     {
  10.         for(int i=1; i<=9; i++)
  11.         {
  12.             for(int j=1; j<=9; j++)
  13.             {
  14.                 System.out.print(i+"x"+j+"="+(i*j)+"\t");
  15.             }
  16.             System.out.println();
  17.         }
  18.     }
  19. }
複製代碼

作者: 粘靖瑜    時間: 2013-1-19 10:30

  1. public static class ch52
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         print99();
  6.     }

  7.     public static void print99()
  8.     {
  9.         for(int i=1; i<=9; i++)
  10.         {
  11.             for(int j=1; j<=9; j++)
  12.             {
  13.                 System.out.print(i+"x"+j+"="+(i+j)+"\t");
  14.             }
  15.             System.out.print()
  16.         }
  17.     }
  18. }
複製代碼





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