在c#中打印星星图案

在c#中打印星星图案

本文介绍了在c#中打印星星图案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在c#中打印这种格式但是没有得到结果 我想要的输出是: - * * b $ b ** ** *** *** **** **** * **** * ***** 任何人都可以帮助我...我已经尝试了我的水平但结果是-ve .. 。请给我发送编程。我写这个编程: -i want to print this format in c# but not getting the resultthe output i want is:-* *** ***** ******* ********* * *****could any one please help me...I've try my level best but the result is -ve...just send me the programming for this. I write this programming:-int number = 5; int i, j, k; for (i = 1; i <= number; i++) { for (j = 1; j <= number - i; j++) { Console.Write(""); } for (k = 1; k <= i; k++) { Console.Write("*"); } Console.WriteLine(""); } for (i = 1; i <= number; i++) { for (j = 1; j <= number - i; j++) { Console.Write(" "); } for (k = 1; k <= i; k++) { Console.Write("*"); } Console.WriteLine(""); } &它打印这个 * ** *** **** ***** * ** *** **** ***** 请尽快寄给我....先谢谢。& it print this*************** * ** *** *********please send me ASAP....thanks in advance.推荐答案试试这个。这似乎有效。Try this. This seems to be working,.int number = 5; for (int i = 0; i < number; ++i) { for (int j = 0; j <= i; ++j) { Console.Write("*"); } if (i != number - 1) { Console.Write(" "); } else { Console.Write(" * "); } for (int j = 0; j <= i; ++j) { Console.Write("*"); } Console.WriteLine(); } 这篇关于在c#中打印星星图案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 13:47