日期:2014-05-20  浏览次数:20714 次

谁能用最简便的方法编写乘法口诀表
大家都交流下,看看大家的编程思想

------解决方案--------------------
这样行不?

for (int i=1; i <=9; i++) {
for (int j=1; j <=i; j++) {
System.out.printf( "%2d ", i*j);
}
System.out.println( " ");
}
------解决方案--------------------
这样行不?
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 ");
------解决方案--------------------
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;
}
}
------解决方案--------------------
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();
}
}

------解决方案--------------------
口诀别就那么一点,直接打印在屏幕不就可以了?
------解决方案--------------------
学习下
------解决方案--------------------
递归九九

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);
    }
  }
}
------解决方案--------------------
System.out.println( "乘法口诀表 ");
------解决方案--------------------
综合比较一下,还是zephyr_cc() 的算法最简单 :)
------解决方案--------------------
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();
}
}
献丑哈
------解决方案--------------------
int i=1;
while(i <=9)
{
j=1;
if(j <=i)
{
printf( "%d*%d=%d ",i,j,i*j);
}