Skip to content

Instantly share code, notes, and snippets.

@FlyingJester
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save FlyingJester/0861f36b49be69fe580d to your computer and use it in GitHub Desktop.

Select an option

Save FlyingJester/0861f36b49be69fe580d to your computer and use it in GitHub Desktop.
const unsigned gWidth = 3;
const unsigned gHeight = 3;
for(unsigned y = 0; y<gHeight; y++){
for(unsigned x = 0; x<gWidth; x++){
// Stuff in here is done once for each x.
// But, it's done gHeight number of times, since this loop is performed inside
// the outer loop!
// So, stuff in here is done gHeight*gWidth times. x and y look like this:
// y, x
// 0 0
// 0 1
// 0 2
// 1 0
// 1 1
// 1 2
// 2 0
//...
}
// Stuff here is done during each of the outer loop's
// iterations, after all the stuff in the inner loop is done.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment