#include<iostream> using namespace std; #define N 10 int arr[N][N]; int main(int argc, char *argv[]) { int data = 1; for (int i = 0,j=0,k=0; k < (N+1)/2; k++) { while (j<N-k) { arr[i][j] = data; j++; data++; } j--; i++; while (i<N-k) { arr[i][j] = data; i++; data++; } i--; j--; while (j>k-1) { arr[i][j] = data; j--; data++; } j++; i--; while (i>k) { arr[i][j] = data; i--; data++; } i++; j++; } for (size_t i = 0; i < N; i++) { for (size_t j = 0; j < N; j++) { cout << arr[i][j]<<"\t"; } cout << endl; } system("pause"); return 0; }