按照你的要求,编写的用星号输出一个梯形的Java程序如下
public class B {
public static void main(String[] args) {
int N=5;
for(int i=1;i<=N;i++){
for(int j=1;j<=N-i;j++){
System.out.print(" ");
}
for(int j=1;j<=2*i+1;j++){
System.out.print("*");
}
System.out.println();
}
}
}
运行结果
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/b7fd5266d016092439add4e3dd0735fae7cd34b9?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)