用JAVA怎么编写99乘法表?用for的循环,请教一下!!

解决方案 »

  1.   

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

  2.   

    不会又是作业题吧~
    public class Test{
     public static void main(String args[]){
      for(int i=1;i<10;i++){
          for(int j=1;j<10;j++)
              System.out.print(j+"*"+i+"="+j*i+"\t");
          System.out.println();
          }
      }
    }
      

  3.   

    楼上没错,不过是不是有点问题:
     System.out.print(i * j + "  ");
    这样i*j的结果就算出来了
    改成System.out.print(i+"*"+ j + "  ");
      

  4.   

    我也改下
    "j<10"改成"j<=i"
      

  5.   

    刚学JAVA  也发一个 请多指教public class Test {
    public  static void  main(String args[]){
    System.out.println("tetst");
    int i,j;
    for(i=1;i<=9;i++){
    j=1;
    while(j<=i){
    System.out.print(""+j+"*"+i+"="+i*j+"  ");
    j++;
    }
    System.out.println();
    }
    }
    }
      

  6.   

    public class Multipliction { public static void main(String[] args) { int i;
    int j;
    for (i = 1; i < 10; i++) {
        for (j = 1; j <= i; j++) {
    System.out.print(j + "*" + i + "=" + j * i + "\t");
    }
      System.out.println();
    }
    }
    }
      

  7.   

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

  8.   

    我也来一下
    呵呵 前几天刚刚学到的
    jdk1.6可以编译printf函数哈,其他好像不好使
    class cfb{
    public static void main(String[] args){
    for(int i=2;i<=9;i++){
    for(int k =1;k<=9;k++){
    System.out.printf("%d*%d=%d\t",i,k,i*k);
    }
    }
    }
    }
      

  9.   

    怀念大学的时光
    public class Test{
     public static void main(String args[]){
      for(int i=1;i<10;i++){
          for(int j = 1;j <= i;j++){
              System.out.print(j+"*"+i+"="+j*i+"\t");
          System.out.println();
          }
      }
    }
      

  10.   

    public class Test99{
    public static void main(String args[]){
    for(int i=1;i<10;i++){
    for(int j=1;j<10;j++)
    System.out.print(j+"*"+i+"="+j*i+"\t");
    System.out.println();
    }
    }
    }记得是学java做的第一道习题
      

  11.   

    public static void main(String[] args)
    {
    for (int i = 1; i < 10; i++)
    {
    for (int j = 1; j <= i; j++)
    {
    System.out.print(j + "*" + i + "=" + i * j + "\t");
    }
    System.out.println(); } }运行结果:
    1*1=1
    1*2=2 2*2=4
    1*3=3 2*3=6 3*3=9
    1*4=4 2*4=8 3*4=12 4*4=16
    1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
    1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
    1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
    1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
    1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81
      

  12.   

    public class ForDemo{
    public static void main(String args[]){
    for (int i=1; i<10; i++)
    System.out.print("  "+i);
    System.out.println();
    for(int i=1; i<10; i++){
    System.out.print(i+"  ");
    for(int j=1; j<10; j++)
    if(i*j>=10)
    System.out.print(i*j+ "  ");
    else
    System.out.print(i*j+ "  ");
    System.out.println();
        }
      }
    }
    程序输出结果为:
       1   2   3   4   5   6   7   8   9  
    1  1   2   3   4   5   6   7   8   9
    2  2   4   6   8  10  12  14  16  18
    3  3   6   9  12  15  18  21  24  27
    4  4   8  12  16  20  24  28  32  36 
    5  5  10  15  20  25  30  35  40  45 
    6  6  12  18  24  30  36  42  48  54 
    7  7  14  21  28  35  42  49  56  63
    8  8  16  24  32  40  48  56  64  72 
    9  9  18  27  36  45  54  63  72  81
      

  13.   

    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");        }
            System.out.println();
         }    }
      

  14.   

    C++
    #include"iostream.h"void main()
    {
    for(int i=1;i<10;i++)
    {
    for(int j=1;j<=i;j++)
    {
    cout<<i<<"*"<<j<<"="<<i*j<<"  ";
    }
    cout<<endl;
    }
    }
      

  15.   

    class Test{
       void Test(int x,int y){
        for(a=0;a<=x;a++){
          for(b=0;b<=y;b++){
            System.out.println("a"+"*"+"b="+a*b);
           }
        }
    }
    }
    public class Test99{
        public class void main(String args[]){
            class Test=new Test(9,9);
        }
    }
    刚学java 呵呵
      

  16.   

    for(i=1;i<10;i++)
    {
       for(j=1;j<=i;j++)
      {
         System.out.println(j+"*"+i+"="+j*i+"\t"
      }
           System.out.println();
        
    }
    刚学java 嘎嘎!!
      
      

  17.   

    public class multi_Table { public static void main(String args[]) {
    for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= i; j++) {
    System.out.print(String.valueOf(j) + "*" + String.valueOf(i)
    + "=" + i * j + "    ");
    }
    System.out.println();
    }
    }
    }
      

  18.   

    1X1=1 
    1X2=2 2X2=4 
    1X3=3 2X3=6 3X3=9 
    1X4=4 2X4=8 3X4=12 4X4=16 
    1X5=5 2X5=10 3X5=15 4X5=20 5X5=25 
    1X6=6 2X6=12 3X6=18 4X6=24 5X6=30 6X6=36 
    1X7=7 2X7=14 3X7=21 4X7=28 5X7=35 6X7=42 7X7=49 
    1X8=8 2X8=16 3X8=24 4X8=32 5X8=40 6X8=48 7X8=56 8X8=64 
    1X9=9 2X9=18 3X9=27 4X9=36 5X9=45 6X9=54 7X9=63 8X9=72 9X9=81
      

  19.   

    /**
       相对来说,这是一个较清晰的九九乘法表(如果有什么地方不好,还望指正)
    */public class Mul
    {
    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+"=");
    if(i*j<10)
    System.out.print(0);
    System.out.print(i*j+"  ");
    }
    System.out.println();
    }
    }
    }
      

  20.   

    顶个吧,我刚开始自学JAVA,嘿嘿,算还看得明一些!
      

  21.   

    public class Test {
    /**
     * @param args
     */
    /**
     * @param args
     */
    public static void main(String[] args){
    for (int i=1;i<=9;i++){
    //System.out.println("i=");
    for (int j=1;j<=i;j++){
    int product=i*j;
    System.out.print(i+"*"+j+ "=" +product+",");
    //System.out.print("*");
    }
    System.out.println();

    }
    }
    }
    结果
    1*1=1,
    2*1=2,2*2=4,
    3*1=3,3*2=6,3*3=9,
    4*1=4,4*2=8,4*3=12,4*4=16,
    5*1=5,5*2=10,5*3=15,5*4=20,5*5=25,
    6*1=6,6*2=12,6*3=18,6*4=24,6*5=30,6*6=36,
    7*1=7,7*2=14,7*3=21,7*4=28,7*5=35,7*6=42,7*7=49,
    8*1=8,8*2=16,8*3=24,8*4=32,8*5=40,8*6=48,8*7=56,8*8=64,
    9*1=9,9*2=18,9*3=27,9*4=36,9*5=45,9*6=54,9*7=63,9*8=72,9*9=81,
      

  22.   

    各位写得大同小异呀,我觉得那个printf不错
      

  23.   

    public class NineTable{
    public static viod main(String[] args){
    for(int i=1;i<10;i++){
      for(int j=1;j<10;j++)
        System.out.println("%d*%d=%2d",i,j,i*j);
         }
      System.out.println();
       }
     }
    自己温习下 看对不对
      

  24.   

    完了 上面那个println改成printf 对不起~~ 呵呵 我也正在学
      

  25.   

    public class Test{
        public static void main(String[] args){
    int i,j;
    for (i=1;i<=9 ;i++){
        for(j=1;j<=i;j++){
            System.out.print(i + "*" + j + "=" + i*j + " ");
                 }
        System.out.println();
    }
        }
    }
      

  26.   

    public class Array{
    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+"="+i*j+" ");
                System.out.println();     
        }
    }
    }
      

  27.   

    public class Prix  
    {
    public static void main(String[] args) 
    {
        /*打印99乘法表    开始*/
        int h,l;
    System.out.println("**********打印99乘法表**********");
    for(h = 0;h <= 9;h++){
               for(l = 0;l < h;l++){
         System.out.print((l+1)+"*"+h+"="+(h*(l+1))+"\t");
       }
       System.out.println();
    }
    /*打印99乘法表    结束*/
    }
    }
      

  28.   

    int i=1;
    int j=1;
    while(i<=9 && j<=9){
    System.out.print(i+"*"+j+"="+(i*j)+"\t");
     if ( j++==i ){
      System.out.print("\n");
      i++;
      j=1;
     }
    }
      

  29.   

    public class multiplication {
    public static void main(String[] args) {
    int a=0;
    for(int i=1;i<=9;i++){
    for(int j=1;j<=i;j++){
    a=i*j;
    System.out.print(i+"*"+j+"="+a+" ");
    }
    System.out.println(" ");
    }
    }}
      

  30.   

    public class S99 {

    public void shou(){
    int i;
    int j; for( i=1;i<10;i++){
    for( j=1;j<=i;j++){
    System.out.print(+j+"x"+i+"=" +(i*j)+"\t" );


    }

    System.out.println();
    }
    }

    public static void main(String[] args) {
    S99 p=new S99();
    p.shou();


    }}1x1=1
    1x2=2 2x2=4
    1x3=3 2x3=6 3x3=9
    1x4=4 2x4=8 3x4=12 4x4=16
    1x5=5 2x5=10 3x5=15 4x5=20 5x5=25
    1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36
    1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49
    1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64
    1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81
      

  31.   

    初学,用C写一个
    #include<stdio.h>
     void main() 
    {
       int a,b,c;
    for(a=1;a<=9;a++)
        {
             for(b=1;b<=a;b++)
                {
                    c=a*b;
                     printf("%d*%d=%2d ",a,b,c); 
                }
           printf("\n");
        }
    }
    go
      

  32.   

    /* main方法 里递归调用 main */
    public class FC4 {
            static int k, l, m;
            static int i, j;
            static String[] s = {"1","1"};
            public static void main(String[] args) {
                    if(args.length>0) {
                            i = Integer.parseInt(args[0]);
                            j = Integer.parseInt(args[1]);
                            if(j == 9) {
                                    System.out.println(i + "*" + j + "=" + i*j + "\t");
                                    return;
                            } else if(i > j) {
                                    System.out.print(i + "*" + j + "=" + i*j + "\t");
                                    j++;
                                    args[1] = new Integer(j).toString();
                            } else {
                                    System.out.print(i + "*" + j + "=" + i*j + "\t");
                                    if(i == j) {
                                            j = 1;
                                            System.out.println();
                                    }
                                    i++;
                                    args[0] = new Integer(i).toString();
                                    args[1] = new Integer(j).toString();
                            }
                    }
                    main(s);
            }
    }
      

  33.   

    抱歉,忘了用for循环了.........
      

  34.   

    自己用FOR做的 感觉还是比较好 可以参考下
    public   class   woyun

    public   static   void   main(String   args[])

    for(int i=9;i>0;i--)

    for(int j=i;(j<=i)&&(j>0);j--) 
    System.out.print(i+"*"+j+"="+j*i+" ");
    System.out.println(" ");
    }

    }