c# code needed...urgent!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rohitscripts
    New Member
    • Apr 2007
    • 16

    c# code needed...urgent!!

    could any one gimme coding ... to have out put like this-

    **********
    ****--****
    ***----***
    **------**
    *--------*
    **------**
    ***----***
    ****--****
    **********
    (note::here, i'm unable post this question with more spaces in between the *s. so,i have inserted - symbol instead of spaces)

    please dont kid by sending code ..jus using response.write.

    thank you
  • vanc
    Recognized Expert New Member
    • Mar 2007
    • 211

    #2
    for i = 0 ----> 5
    {
    for j = 0 ----> 5 - i
    write *
    for k = 0 ----> i*2
    write -
    for j = 0 ----> 5-i
    write *
    }

    reverse this loop to get full output

    cheers,
    Van.

    Comment

    • vanc
      Recognized Expert New Member
      • Mar 2007
      • 211

      #3
      string output="";

      for(int j = 0;j <5; j++)
      {
      for (int i = 0; i < 5 - j; i++)
      output += "*";
      for (int k = 0; k < j * 2; k++)
      output += "-";
      for (int i = 0; i < 5 - j; i++)
      output += "*";
      output += "\n";
      }
      for (int j = 5; j < 9;j++ )
      {
      for (int i = 0; i < j-3; i++)
      output += "*";
      for (int k = 0; k < (8-j) * 2; k++)
      output += "-";
      for (int i = 0; i < j-3; i++)
      output += "*";
      output += "\n";
      }

      Cheers.

      Comment

      Working...