Skip to content

Instantly share code, notes, and snippets.

@games
Last active August 27, 2015 07:10
Show Gist options
  • Select an option

  • Save games/1bf64d07d7c19082cf92 to your computer and use it in GitHub Desktop.

Select an option

Save games/1bf64d07d7c19082cf92 to your computer and use it in GitHub Desktop.
#include <iostream>
// { 1 2 3 4 }
// { 5 6 7 8 }
// { 9 10 11 12 }
// {13 14 15 16 }
//
// 4
// 3 8
// 2 7 12
// 1 6 11 16
// 5 10 15
// 9 14
// 13
//
int main() {
int arr[4][4] = {
{ 1, 2, 3, 4},
{ 5, 6, 7, 8},
{ 9, 10, 11, 12},
{13, 14, 15, 16}
};
for (int i = 3; i >= -3; --i) {
for (int j = 0; j <= 3; ++j) {
int y = i + j;
if (y >= 0 && y <= 3) {
std::cout << arr[j][y] << " ";
}
}
std::cout << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment