本篇文章扣丁学堂Java培训小编给读者们简单分享一下如何用C#随机数生成字母金字塔,具有一定的参考价值,感文中有详细的代码列出供感兴趣的小伙伴参考,想要了解的小伙伴就随小编来看一下具体内容吧。
代码实现:
static void Main(string[] args)
{
showNpoint(25);
Console.ReadKey();
}
private static void showNpoint(int count)
{
Random r = new Random();
string[] strE = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
for (int i = 1; i <=count; i++)
{
for (int j = 1; j <=count-i; j++)
{
Console.Write(" ");
}
for (int k = 1; k <= 2*i-1; k++)
{
Console.Write(strE[r.Next(0,25)]);
}
Console.WriteLine();
}
}
以上就是扣丁学堂Java在线学习小编给大家分享的如何用C#随机数生成字母金字塔,希望对小伙伴们有所帮助,想要了解更多内容的小伙伴可以登录扣丁学堂官网咨询。
想要学好Java开发小编给大家推荐口碑良好的扣丁学堂,扣丁学堂有专业老师制定的Java学习路线图辅助学员学习,此外还有与时俱进的Java课程体系和Java视频教程供大家学习,想要学好Java开发技术的小伙伴快快行动吧。扣丁学堂Java技术交流群:850353792。
有疑问加站长微信联系(非本文作者)