解题输入一个字符,最后输出金字塔

字符金字塔

http://www.nowcoder.com/questionTerminal/0fae60c3b5c64699b7c0f031c2187dde

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Object object = scanner.next();
        testA(object);

    }

    public static void testA(Object obj){
        String a = " ";
        int x = 1;
        for (int i = 5 ; i > 0 ; i--){
            for (int j = 0 ; j < i - 1; j++){
                System.out.print(a);
            }

            for (int k = 1 ; k <= x*2 -1 ; k++){
                if (k%2==0){
                    System.out.print(a);
                }else {
                    System.out.print(obj);
                }
            }
            x++;
            System.out.println();
        }
    }
}
全部评论

相关推荐

2025-12-16 12:46
河北农业大学 Java
king327:最好要在简历中很好地包装和证明你的能力 要证明你的技术深度才能在面试官那里有竞争力 如果你有需要的话可以看一下我主页简历我帮你详细地说一下各个地方的具体问题
实习简历求拷打
点赞 评论 收藏
分享
2025-12-15 14:16
门头沟学院 Java
回家当保安:发offer的时候会背调学信网,最好不要这样。 “27届 ”和“28届以下 ”公司招聘的预期是不一样的。
实习简历求拷打
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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