Skip to content

Instantly share code, notes, and snippets.

@jnericks
Created April 24, 2013 20:40
Show Gist options
  • Select an option

  • Save jnericks/5455397 to your computer and use it in GitHub Desktop.

Select an option

Save jnericks/5455397 to your computer and use it in GitHub Desktop.

Revisions

  1. jnericks created this gist Apr 24, 2013.
    34 changes: 34 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    using System;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    int x = 4;
    int y = 6;

    printGrid(x, y);

    Console.Read();
    }

    static void printGrid(int x, int y)
    {
    for (int a = 1; a <= x; a++)
    {
    var val = a; // this is what you are missing
    Console.Write(val + " ");

    for (int b = 1; b < y; b++)
    {
    val = val + x;
    Console.Write(val + " ");
    }

    Console.WriteLine();
    }
    }
    }
    }