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

牛牛的字符菱形

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

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string to =Console.ReadLine();
            for (int i = 0; i < 5; i++)
            {
                int spaceNum=Abs(i+1,3);
                for (int j = 0; j < 5; j++)
                {
                  if ((j+1)<=spaceNum||(j+1)>5-spaceNum)
                  {
                      Console.Write(" ");
                  }else
                  {
                      Console.Write(to);
                  }
                   
                }
                Console.Write("\n");
               
            }

        }
        private static int Abs(int a,int b)
        {
           if(a>b)
           {
               return a-b;
           }
            else
            {
                return b-a;
            }
        }
    }
}
全部评论

相关推荐

程序员饺子:正常 我沟通了200多个 15个要简历 面试2个 全投的成都的小厂。很多看我是27直接不会了😅
点赞 评论 收藏
分享
争当牛马还争不上
码农索隆:1.把简历改哈 2.猛投,狠投 3.把基础打牢 这样你在有机会的时候,才能抓住
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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