Skip to content

Instantly share code, notes, and snippets.

@jnericks
Created April 24, 2013 20:40
Show Gist options
  • Save jnericks/5455397 to your computer and use it in GitHub Desktop.
Save jnericks/5455397 to your computer and use it in GitHub Desktop.
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();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment