返回列表 發帖

九九乘法表 (一)

利用巢狀迴圈,寫一個排列整齊的九九乘法表如下圖所示。
提示:\t 代表鍵盤上的Tab鍵,可用來對齊。

  1. public class Ch14 {

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

  1. public class Ch12{
  2.         public static void main(String args[])
  3.         {
  4.                 int i=1;
  5.                 while(i<=9)
  6.                 {
  7.                         int j=1;

  8.                         while(j<=9)
  9.                         {
  10.                                 System.out.print((i+"x"+j+"="+(i*j)+"\t"));
  11.                                 j++;
  12.                         }
  13.                         i++;
  14.                         System.out.println();

  15.                 }
  16.         }

  17. }
複製代碼

TOP

  1. public class Ch11
  2. {

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

  19. }
複製代碼

TOP

  1. public class Ch56 {

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

TOP

  1. public class Ch17 {

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

  13. }
複製代碼

TOP

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

TOP

  1. public class Ch12 {

  2.         public static void main(String[] args) {

  3.                 for(int i=1; i<=9; i+=1)
  4.                 {       
  5.                         for(int j=1; j<=9; j+=1)
  6.                         {
  7.                                 System.out.print(i+"x"+j+"="+(i*j)+"\t");
  8.                         }
  9.                         System.out.println();

  10.                 }
  11.         }
  12. }
複製代碼

TOP

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

TOP

  1. public class umohahyah {

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

  12. }
複製代碼

TOP

  1. public class Ch18 {

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

  12. }
複製代碼

TOP

  1. public class Ch12
  2. {

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

  13. }
複製代碼

TOP

  1. public class Ch14 {

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

TOP

  1. public class Ch11
  2. {

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

  15. }
複製代碼

TOP

  1. public class Ch12 {

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




  16.         }
複製代碼

TOP

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

TOP

返回列表