题解 | #金字塔图案#

金字塔图案

http://www.nowcoder.com/practice/d84e8339f9444bb6b29bd3f227c8e538

import java.util.Scanner;
import java.util.Collections;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            int num = scan.nextInt();
            for(int i = 1; i <= num; i++) {
                System.out.println(String.join("", Collections.nCopies(num - i, " ")) + 
                                 String.join("", Collections.nCopies(i, "* ")));
            }
        }
    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 13:54
点赞 评论 收藏
分享
06-25 09:33
厦门大学 Java
程序员饺子:现在日常估计没啥hc了,等到八月多估计就慢慢有了。双九✌🏻不用焦虑的
投递快手等公司7个岗位
点赞 评论 收藏
分享
06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务