Clean C++ Solution
\n# Code\n\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int r, int c) {\n        vector<vector<int>> directions = {{0
\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int r, int c) {\n        vector<vector<int>> directions = {{0, 1}, {1, 0}, {0, -1}, {-1,0}};\n        int steps=1;\n        int i=0;\n        vector<vector<int>> res;\n        while(res.size()<rows*cols)\n        {\n            for(int j=0;j<2;j++){\n                for(int k=0;k<steps;k++)\n                {\n                    if(0<=r && r<rows && 0<=c && c<cols)\n                    {\n                        res.push_back({r,c});\n                    }\n                    r=r+directions[i][0];\n                    c=c+directions[i][1];\n                }\n                i=(i+1)%4;\n            }\n            steps++; \n        }\n        return res;\n    }\n};\n```
['C++']