public class Demo {
public static void main(String[] args) {
/**打印乘法口诀表
* @author happyboy
* */
for(int i=1;i<=9;i++){
for (int j=1;j<=i;j++){
System.out.print(j+"*"+i+"="+(i*j)+"\t");
}
System.out.println("\n");
}
}
}
打印三角形
public class Demo {
public static void main(String[] args) {
/**打印三角形
* @author happyboy
* */
int line = 5;//定义行数
for (int x = 0; x < line; x++) {
for (int y = 0; y < line - x; y++) {
System.out.print(" ");//控制每行前方空格数目
}
for (int y = 0; y <= x; y++) {
System.out.print("* ");
}
System.out.println();//换行
}
}
}