JAVA的九九乘法表

public static void main(String[] args) {

//第一种
  int a = 1;
  int f = 0;
  while (a < 10) {
   for (int d = 1; d <= a; d++) {
    f = a * d;
    System.out.print(a + "*" + d + "=" + f + "  ");
   }
   System.out.println();
   a++;
  }

//第二种

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

猜你喜欢

转载自blog.csdn.net/qq_41690927/article/details/79207935