用For或While循环写出99乘法表
作者:互联网
1 package com.xl.struct; 2 3 public class ForDemo04 { 4 public static void main(String[] args) { 5 //1.我们先打印第一列,这个大家应该都会 6 //2.我们把固定的1再用一个循环包起来 7 //3.去掉重复项, i<=j 8 //4.调整样式 9 for (int j = 1; j <= 9; j++) { 10 for (int i = 1; i <= j; i++) { 11 System.out.print(j+"*"+i+"="+(j*i)+"\t"); 12 13 } 14 System.out.println(); 15 16 } 17 18 19 } 20 }
1 package com.xl.exercise; 2 3 public class WhileForDemo04 { 4 public static void main(String[] args) { 5 int i,j; 6 j=1; 7 while (j<=9){ 8 i=1; 9 while (i<=j) { 10 System.out.print(i + "*" + j + "=" + i * j + "\t"); 11 i++; 12 } 13 j++; 14 System.out.println(""); 15 } 16 } 17 18 }
标签:xl,void,args,99,While,static,main,乘法表,public 来源: https://www.cnblogs.com/x5253/p/15937909.html