C#随机数生成字母金字塔
程序员文章站
2023-12-14 19:51:34
本文实例为大家分享了c#随机数生成字母金字塔的具体代码,供大家参考,具体内容如下
1. 代码实现:
static void main(string[] args...
本文实例为大家分享了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. 运行结果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。