如何制作三角形? [英] how to make triangle?
本文介绍了如何制作三角形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码 -
My code-
int a = Convert.ToInt32(TextBox1.Text);
for (int i = 1; i <= a; i++)
{
for (int j = a; j >= i; j--)
{
Response.Write("*");
}
Response.Write("<br />");
}
但是我的输出三角形是5比1我想要三角形结构1到5
But my out put triangle is 5 to 1 i want to triangle structur 1 to 5
推荐答案
嘿,这很简单
你只是在第二次循环中做了一个简单的错误
Hey it's simple thing
You are just doing a simple wrong thing in second loop
int a = Convert.ToInt32(TextBox1.Text);
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <=i; j++)
{
Response.Write(" * ");
}
Response.Write("<br>");
}
这篇关于如何制作三角形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文