#include<iostream>
using namespace std;
const int N = 1005;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int m, n, a[N][N];
int main(void){
cin >> m >> n;
int dir = 0, cnt = 1, x = 0, y = 0, nx = 0, ny = 0;
for (int i = 0; i < m * n; i ++ ){
a[nx][ny] = cnt ++ ;
nx = x + dx[dir];
ny = y + dy[dir];
if (a[nx][ny] || nx < 0 || nx >= m || ny < 0 || ny >= n){
dir = (dir + 1) % 4;
nx = x + dx[dir];
ny = y + dy[dir];
}
x = nx;
y = ny;
}
for (int i = 0; i < m; i ++ ){
for (int j = 0; j < n; j ++ )
cout << a[i][j] << ' ';
cout << endl;
}
return 0;
}
03-08
1814
05-06
3万+