public class test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(i+"*"+j+"="+(i*j)+" ");
}
System.out.println();
}
}
}
2.pngpublic class test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 1; i <= 9; i++) {// 控制行
// 用来控制每行空格的数量
for (int k = 1; k <= 9 - i; k++) {
System.out.print(" \t");
}
for (int j = 1; j <= i; j++) {// 控制列
System.out.print(j + "*" + i + "=" + (i * j) + "\t");
}
System.out.println();
}
}
}
3.pngpublic class test3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 9; i >= 1; i--) {
for (int k = 1; k <= 9 - i; k++) {
System.out.print(" \t");
}
for (int j = 1; j <= i; j++) {
System.out.print(j + "*" + i + "=" + (i * j) + "\t");
}
System.out.println();
}
}
}
4.pngpublic class test4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i=9; i>=1; i--) {
for (int j=1; j<=i; j++) {
System.out.print(j+"*"+i+"="+(i*j)+"\t");
}
System.out.println();
}
}
}
网友评论