Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
output
1
2
10
9
3
4
8
7
5
6
Posted
Updated 2-Jul-13 23:04pm
v4

Here is one way:
C#
static void Main(string[] args)
    {
    Console.WriteLine("1");
    Console.WriteLine("2");
    Console.WriteLine("10");
    Console.WriteLine("9");
    Console.WriteLine("3");
    Console.WriteLine("4");
    Console.WriteLine("8");
    Console.WriteLine("7");
    Console.WriteLine("5");
    Console.WriteLine("6");
    Console.ReadLine();
    }

Here is another:
C#
static void Main()
    {
    int[] data = new int[] { 1, 2, 10, 9, 3, 4, 8, 7, 5, 6 };
    foreach (int i in data)
        {
        Console.WriteLine("I'm too lazy to write my own code: {0}", i);
        }
    Console.ReadLine();
    }
 
Share this answer
 
Comments
Pheonyx 3-Jul-13 5:20am    
Second one is the best ;-)
Richard MacCutchan 3-Jul-13 5:28am    
The first one has a sort of classical symmetry.
OriginalGriff 3-Jul-13 5:32am    
Nah, if I'd sorted it, it wouldn't have the right order...:laugh:
Tony Tom.k 6-Jul-13 3:15am    
LOL
Use this solution
Design:

XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
    </form>
</body>
</html>
------------------------------------
Code:

<pre lang="xml">protected void Button1_Click(object sender, EventArgs e)
    {
        int n = 0;
        n = Convert.ToInt32(TextBox1.Text);
        int j = 0;
        for (int i = 1; i &lt; (n/2)+1; i++)
        {

            if (i % 2 == 1)
            {
                Response.Write((n - (n - i))+&quot;&lt;/br&gt;&quot;);
                Response.Write((n - (n - (i + 1))) + &quot;&lt;/br&gt;&quot;);
            }
            else
            {

                Response.Write((n - j) + &quot;&lt;/br&gt;&quot;);
                Response.Write((n - (j + 1)) + &quot;&lt;/br&gt;&quot;);
                j+=2;
            }
        }
    }</pre>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900