using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 打印菱形图案
{
class Program
{
static void Main(string[] args)
{
Print p = new Print();
Console.WriteLine("请输入组成菱形字符(长度为1的字符):");
var str = Console.ReadLine();
Console.WriteLine("请输入菱形上半身高度(为使不影响效果不要大于10):");
int cenNum = Int32.Parse(Console.ReadLine());
p.show(str, cenNum);
Console.ReadKey();
}
}
class Print
{
public void show(string str, int cenNum)
{
//string str = "*";
string strBei = str;
string strk = " ";
//int cenNum = 4;
for (int j = 0; j < cenNum; j++)
{
strk += strk;
}
for (int i = 0; i < cenNum; i++)
{
Console.WriteLine(strk + str);
strk = strk.Substring(0, strk.Length - 1);//去除最后一个空格
str += strBei + strBei;
}
str = str.Substring(0, str.Length - 2);
strk += " ";
for (int k = 0; k < cenNum - 1; k++)
{
strk += " ";
str = str.Substring(0, str.Length - 2);//去除最后两个星号
Console.WriteLine(strk + str);
}
}
}
}
C # 인쇄 다이아몬드 패턴
추천
출처blog.csdn.net/qq_39072819/article/details/92796049
추천
행