写一个简单for循环输出一个等腰三角形。。求解答!!

programerwen 2012-05-24 10:09:09
for(int i=0;i<=5;i++){
for(int j=0;j<=i;j++){

System.out.print("*");
}
System.out.println();
}



这是输出一个直角三角形的代码,我想把它改成一个等腰三角形的,求各位牛人解答!!
...全文
858 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
taney_911 2012-05-24
  • 打赏
  • 举报
回复
int i=Integer.parseInt(args[0]);
for(int x=1;x<=i;x++){

for(int y=i-x;y>=0;y--){
System.out.print(" ");
}
for(int a=1;a<=(2*x-1);a++){
System.out.print("*");
}
System.out.println("");
}

}
阿里路西亚 2012-05-24
  • 打赏
  • 举报
回复
public static void main(String[] args) {

for(int i=0;i<=5;i++){
for(int j=0;j<=4-i;j++){
System.out.print(" ");
}
for(int q=0;q<=i;q++){
System.out.print("*");
}
for(int e=1;e<=i;e++){
System.out.print("*");
}
System.out.println();
}
}

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧