asp.net - A pyramid using backward and forward slashes -


how can write program take integer input base width of pyramid , make appear this: enter image description here

thanks!

aspx:

width:<asp:textbox id="textbox1" runat="server"></asp:textbox> <asp:button id="button1" runat="server" onclick="button1_click1"          text="show pyramid" /> <br /><br /> <asp:label id="label1" runat="server"></asp:label> 

code behind:

protected void button1_click1(object sender, eventargs e) {     label1.text = "";     int width = int.parse(textbox1.text);     int widthbetween = 4;     int firstspace = 5 + width - 1;     (int k = 0; k < firstspace + 2; k++)     {          label1.text+="&nbsp;";     }     label1.text += "^<br>";     (int = 0; < width; i++)     {         (int j = 0; j < firstspace; j++)         {             label1.text += "&nbsp;";         }         label1.text += "/";         (int m = 0; m < widthbetween; m++)         {             if (i == width - 1)             {                 if (m > (widthbetween / 2 - 1))                     break;                 label1.text += "_";             }             else             {                 label1.text += "&nbsp;";             }         }         label1.text += @"\<br>";         widthbetween += 2;         firstspace--;     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -