20181206

int i, j, k,max,min;

min = Convert.ToInt32(textBox1.Text);

max = Convert.ToInt32(textBox2.Text);

string _star, _space;

label1.Text = label2.Text = "";

_star = "*";

_space = " ";

try

{

min = Convert.ToInt32(textBox1.Text);

max = Convert.ToInt32(textBox2.Text);

for (i = max; i > 0 ; i--) {

label1.Text += i.ToString(); //第一題

for(j=max-i-1;j>=0;j--)

{

label1.Text += _space; //第一題

}

for (k = 1; k <= 2 * i - 1; k++)

{

if (i>=min)

label1.Text += _star; //第一題

}

label1.Text += "\n";//第一題

}

//===============第二題==================================================

_star = " ";

_space = "*";

for(k=1;k<=2*max+1;k++)

label2.Text += _space;

label2.Text += "\n";

for (i = 1; i <= max; i++)

{

for (j = max - i ; j >= 0; j--)

{

label2.Text += _space;

}

for (k = 1; k <= 2 * i - 1; k++)

{

if(k == i )

label2.Text += _space;

else

label2.Text += _star;

}

for (j = max - i ; j >= 0; j--)

{

label2.Text += _space;

}

label2.Text += "\n";//第一題

}

for (i = max-1; i >= 0; i--)

{

for (j = max - i ; j >= 0; j--)

{

label2.Text += _space;

}

for (k = 1; k <= 2 * i - 1; k++)

{

if (k == i )

label2.Text += _space;

else

label2.Text += _star;

}

for (j = max - i ; j >= 0; j--)

{

if( i!=0 | j!=0 )

label2.Text += _space;

}

label2.Text += "\n";//第一題

}

//===============END OF 第二題==================================================

}

catch { }