大家都交流下,看看大家的编程思想

解决方案 »

  1.   

    这样行不?for (int i=1; i<=9; i++) {
        for (int j=1; j<=i; j++) {
            System.out.printf("%2d ", i*j);
        }
        System.out.println("");
    }
      

  2.   

    这样行不?
    System.out.print(
         " 1 \n" + 
         " 2  4 \n" + 
         " 3  6  9 \n" + 
         " 4  8 12 16 \n" + 
         " 5 10 15 20 25 \n" + 
         " 6 12 18 24 30 36 \n" + 
         " 7 14 21 28 35 42 49 \n" + 
         " 8 16 24 32 40 48 56 64 \n" + 
         " 9 18 27 36 45 54 63 72 81 \n");
      

  3.   

    import java.util.*;
    public class MultipleTable
    {    public static void main(String[]args)
         {  MultipleTable mt = new MultipleTable();        int initNum = 9;
    int res = 0;
    for(int i = 1; i<=initNum; i++)
    {   for(int j = 1;j<= i;j++)
        {  res = i * j;
           mt.printFormula(i,j,res);
        }
        System.out.print("\n");
    }
         }
         public void printFormula(int i,int j,int res)
         {  System.out.print(i+ "*"+j+"="+res +  " ");
         }
    }
      

  4.   

    int i ,j ;

    for( i = 1,j = 1 ; i <= 9 ; j++){

    System.out.print(j + "*" + i + "=" + i*j + "  ");

    if(j == i){
    j = 0;
    i++;
    System.out.println();
    continue;
    }
    }
      

  5.   

    class 九九
    {int n;
     public 九九(int n)
     {this.n=n;}
       void a() 
       {int i,j;
       for(i=1;i<=n;i++)
        {
          for(j=1;j<=i;j++)
           {
             System.out.print(j+"*"+i+"="+j*i+"\t");
             if(j==i) {System.out.println();}       
           }      
        }
     }  }
       public class 九九表
     {
      public static void main(String args[])
      {九九 p1=new 九九(9);
       p1.a();
      }
     } 
      

  6.   

    再给你缩下水 
     public class biao
     {
      public static void main(String args[])
      {for(int i=1;i<=9;i++)
        {
          for(int j=1;j<=i;j++)
           {
             System.out.print(j+"*"+i+"="+j*i+"\t");
             if(j==i) {System.out.println();}       
           }      
        }
      }

      

  7.   

    不好意思
    continue; 去掉
      

  8.   

    递归九九public class Test2 {

      public static void main(String[] args) {
        table99(1, 1);
      }
      
      public static void table99(int row, int col) {
        if(col <= 9) {
          System.out.printf("%1d*%1d=%2d", row, col, row*col);
          String separator = "";      
          if(row == col) {
            row = 1;
            col = col + 1;        
            separator = "\n";
          }else{
            row = row + 1;
            separator = " ";
          }
          System.out.print(separator);
          table99(row, col);
        }
      }
    }
      

  9.   

    System.out.println("乘法口诀表 ");
      

  10.   

    for(int i = 1;i<10;i++)
            {
                for(int j = 1;j<i+2;j++)
                {
                    if(j==i+1) System.out.println();
                    else
                        System.out.print(i*j+",");
                }
            }
      

  11.   

    综合比较一下,还是zephyr_cc() 的算法最简单 :)
      

  12.   

    zephyr_cc() 的算法岂止简单哦,简直妙不可言啊
    public static void main(String[] args) {
      for(int i = 1; i < 10; i++) {
        for(int j = 1; j <= i; j++) {
          System.out.print(i + "*" + j + " = " + i * j + \t);
        }
        System.out.println();
      }
    }
    献丑哈
      

  13.   

    int i=1;
    while(i<=9)
    {
      j=1;
      if(j<=i)
      {
        printf("%d*%d=%d",i,j,i*j);
      }
      else
      {
        j++;
      }
      i++;
    }
      

  14.   

    这样行不?
    System.out.print(
        " 1 \n" + 
        " 2  4 \n" + 
        " 3  6  9 \n" + 
        " 4  8 12 16 \n" + 
        " 5 10 15 20 25 \n" + 
        " 6 12 18 24 30 36 \n" + 
        " 7 14 21 28 35 42 49 \n" + 
        " 8 16 24 32 40 48 56 64 \n" + 
        " 9 18 27 36 45 54 63 72 81 \n");这个最好,你们还得循环那么多次,这个效率最高.
      

  15.   

    for(int i=1;i<=9;i++)
    {
      for(int j=1;j<=i;j++)
      {
         System.out.print(j+"*"+i+"="+j*i+"  ");
      }
      System.out.println();
    }
      

  16.   

    class 乘法表
    {
        public static void main (String[] args)
        {
         for(int i=1;i<10;i++)
         {
         for(int j=1;j<10;j++)
         {
         if(i*j<10)
         {
         System.out.print("i*j="+" "+i*j+" ");
         }
         else
         {
         System.out.print("i*j="+i*j+" ");
         }
        
         if(i==j)
         {
         System.out.println("");break;
         }
        
            }
         }
        }
    }