目录
一问题:
编辑二代码:
三运行结果:
四问题
二代码:
三运行结果:
一问题:
二代码:
package 重修;
import java.util.Random;
import java.util.Scanner;
public class first {
public static void main(String[] args) {
koujuebiao();
}
private static void koujuebiao() {
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <=i ; j++) {
System.out.print(j+"*"+i+"="+i*j+" ");
}
System.out.println();
}
}
}
三运行结果:
四问题
二代码:
package 重修;
import java.util.Random;
import java.util.Scanner;
public class first {
public static void main(String[] args) {
System.out.println("请决定打印几行三角形");
Scanner sc=new Scanner(System.in);
int x;
x= sc.nextInt();
sanjiaoxingg(x);
}
private static void sanjiaoxingg(int x) {
for (int i = 1; i <= x; i++) {
for (int j = 1; j <= x-i; j++) {
System.out.print(" ");
}
for (int j = 1; j <=i ; j++) {
System.out.print("* ");
}
System.out.println();
}
}
}