30 int startRow = 0, endRow = r - 1;
31 int startCol = 0, endCol = c - 1;
34 while (startRow <= endRow && startCol <= endCol) {
36 for (
int i = startCol; i <= endCol; i++, cnt++) {
37 std::cout << a[startRow][i] <<
" ";
42 for (
int i = startRow; i <= endRow; i++, cnt++) {
43 std::cout << a[i][endCol] <<
" ";
52 for (
int i = endCol; i >= startCol; i--, cnt++) {
53 std::cout << a[endRow][i] <<
" ";
61 for (
int i = endRow; i >= startRow; i--, cnt++) {
62 std::cout << a[i][startCol] <<
" ";