题解 | #牛牛的字符菱形#

牛牛的字符菱形

https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char ch = in.next().charAt(0);
        for(int i=1;i<=5;i++)
        {
            int a=Math.abs(3-i);
            int b=5-2*a;
            for(int j=0;j<a;j++)
            {
                System.out.printf(" ");
            }
            for(int j=0;j<b;j++)
            {
                System.out.printf("%c",ch);
            }
            System.out.println();
        }
    }
}

全部评论

相关推荐

新记话事人:你就和她说去抖音了
点赞 评论 收藏
分享
什么时候才能有offer啊_:十年前我还在刺激战场研究跳伞的底层原理呢
投递牛客等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务