for循环
public class qwe{
public static void main(String [] args){
int num3=1;
for (int num1=1;num1<=9;num1++){
for (int num2=1;num2<=num1;num2++){
num3=num1*num2;
System.out.print(num1+"X"+num2+"="+num3+"\t");
}
System.out.println();
}
}
}
while循环
public class Xunhuan21{
public static void main(String [] args){
int num1 = 1;
int num2 = 1;
int num3;
while (num1<=9){
num2=1;
while (num2<=num1){
num3=num1*num2;
System.out.print(num1+"X"+num2+"="+num3+"\t");
num2++;
}
num1++;
System.out.println();
}
}
}