Created
September 21, 2017 09:45
-
-
Save invatainfo/6afb4a1a4fa9eec7d1823dc1295f5faf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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