仅使用for循环形成*模式 [英] forming * patterns using only for loops
本文介绍了仅使用for循环形成*模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
连续三角形的先前版本已完成,并且如果对菱形等四个方向的图形有适当的帮助.
the previous version of consecutive triangles is done and if any help on figures in four directions like rhombus in proper order.
推荐答案
以下是C的一些示例-您可以轻松地将它们移植到.NET:
http://www.interviewmantra.net/2009/10/10-star-pattern- program.html [^ ]
Here are some samples for C - you may easily port them to .NET:
http://www.interviewmantra.net/2009/10/10-star-pattern-programs.html[^]
最喜欢的作业主题之一
``*''模式程序就像拼图一样,喜欢解决它.
一些参考如下
http://forum.notebookreview.com/programming-homework-questions/370222-simple-star-pattern-c.html [ ^ ]
http://www.softwareandfinance.com/CSharp/Loops_Diamond_Pattern.html [ http://www.csharphub.com/2011/03/how-to-write-c-program-to-print-star.html [
One of the Favorite homework topics
''*'' pattern programs are like puzzles so, enjoy solving it.
some references as below
http://forum.notebookreview.com/programming-homework-questions/370222-simple-star-pattern-c.html[^]
http://www.softwareandfinance.com/CSharp/Loops_Diamond_Pattern.html[^]
http://www.csharphub.com/2011/03/how-to-write-c-program-to-print-star.html[^]
Happy Coding!
:)
hiii,
我认为这会帮助您
hiii,
i think this one will help you
class Program
{
static void Main(string[] args)
{
int i, j, k, n;
Console.Write("Enter the No. :");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n + (n - 1); i++)
{
for (j = 1; j <= n + (n - 1); j++)
{
if (i + j == (n + 1) || i + j == (n + n + n - 1) || i - j == (n -
1) || i - j == -(n - 1))
Console.Write("*");
else
Console.Write(" ");
}
Console.WriteLine("\n");
}
Console.Read();
}
}
这篇关于仅使用for循环形成*模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文