题解 | #牛牛的字符菱形#
牛牛的字符菱形
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;
}
}
}
}
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;
}
}
}
}