打印乘法表
描述:三种循环打印九九乘法表
源代码:
public class Multiple {
public static void main(String[] args) {
System.out.println("-------------------------for循环输出-----------------------------");
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();
}
System.out.println();
System.out.println("-------------------------while循环输出-----------------------------");
int rows = 1;
while(rows<10){
int columns = 1;
while(columns<=rows){
System.out.print(columns+"×"+rows+"="+(rows*columns)+"\t");
columns++;
}
System.out.println();
rows++;
}
System.out.println();
System.out.println("-------------------------do-while循环输出-----------------------------");
int r = 0;
do{
r++;
int c = 0;
do{
c++;
System.out.print(c+"×"+r+"="+(r*c)+"\t");
}while(c<r);
System.out.println();
}while(r<9);
System.out.println();
}
}