Last active
November 16, 2015 03:34
-
-
Save offchan42/244a614556186693f97d to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
cin >> n; | |
int fields[50][50] = {}; // set to zero | |
for (int i = 0; i < n; i++) { | |
int v = i+1; | |
fields[0][i] = v; | |
fields[n-1][i] = v; | |
fields[i][0] = 1; | |
fields[i][n-1] = n; | |
fields[i][i] = v; | |
fields[n-1-i][i] = v; | |
} | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < n; j++) { | |
if (fields[i][j]) cout << fields[i][j] << ' '; | |
else cout << " "; | |
} | |
cout << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment