十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这期内容当中小编将会给大家带来有关C#中怎么利用随机数生成字母金字塔,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
专注于为中小企业提供成都做网站、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业玉环免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
1. 代码实现:
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(); } }
2. 运行结果:
上述就是小编为大家分享的C#中怎么利用随机数生成字母金字塔了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。