Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 21, 2017 09:45
Show Gist options
  • Save invatainfo/6afb4a1a4fa9eec7d1823dc1295f5faf to your computer and use it in GitHub Desktop.
Save invatainfo/6afb4a1a4fa9eec7d1823dc1295f5faf to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main() {
int n,a[25][25],i,j;
cin >> n;
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
if (i + j == n + 1)
a[i][j] = 0;
else if (i + j < n + 1)
a[i][j] = j;
else
a[i][j] = n - i + 1;
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++)
cout << a[i][j] << " ";
cout << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment