import java.util.Scanner;
public class Demo1_1 {
public static void main(String[] args) {
int a,b,c,d;
Scanner sc = new Scanner(System.in);
System.out.println("请输入金字塔层数:");
a = sc.nextInt();
for(b=1;b<=a;b++){
for(c=1;c<=a-b;c++){
System.out.println(" ");
}
for(d=1;d<=2b-1;d++){
System.out.println("*");
}
System.out.println("\n");
}
}
}
Die Ausnahme zeigt:Syntaxfehler auf Token "b", löschen Sie dieses Token
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error on token "b", delete this token at none.Demo1_1.main(Demo1_1.java:15)
Was mit den B-Token falsch?
Es gibt Fehler in dieser Zeile 'für (d = 1; d <= 2b-1; d ++) ' –