如何使用JAVA一层for循环打印出倒立三角形

 我来答
gdmmd
推荐于2017-09-18 · TA获得超过1279个赞
知道大有可为答主
回答量:1581
采纳率:66%
帮助的人:1037万
展开全部

以下代码仅供参考

public static void main(String[] args) {
        int maxRow = 5;
        for (int currentIndex = 0, currentRow = 0; currentRow < maxRow;) {

            if (currentIndex % maxRow < currentRow) {
                System.out.print(" ");
            } else {
                System.out.print("* ");
            }

            currentIndex++;
            if (currentIndex % maxRow == 0) {
                System.out.println("\r");
                currentRow++;
            }

        }
    }
学生族aoe
2015-10-02 · 超过47用户采纳过TA的回答
知道小有建树答主
回答量:164
采纳率:0%
帮助的人:48.8万
展开全部
public class triangle {
public static void main(String[] args){
int a=6;
for(int i=5;i>=0;i--){
System.out.print("@");
if(i==0){
i=--a;
System.out.println();
}
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式