Simple C++ solution
\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int R, int C, int x, int y) {\n        \n        vector<vector<int>>sol;\n        int n = 0
```\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int R, int C, int x, int y) {\n        \n        vector<vector<int>>sol;\n        int n = 0;\n        int step=1;\n\twhile(n<R*C){\n\n\t\tfor (int i = 0; i < step; ++i)\n\t\t{\n\t\t\tif(x>=0 and x<R and y>=0 and y<C)sol.push_back(vector<int>{x,y}),n++;\n\t\t\ty++;\n\t\t}\n\t\tfor (int i = 0; i < step; ++i)\n\t\t{\n\t\t\tif(x>=0 and x<R and y>=0 and y<C)sol.push_back(vector<int>{x,y}),n++;\n\t\t\tx++;\n\t\t}\n\t\tstep++;\n\t\tfor (int i = 0; i < step; ++i)\n\t\t{\n\t\t\tif(x>=0 and x<R and y>=0 and y<C)sol.push_back(vector<int>{x,y}),n++;\n\t\t\ty--;\n\t\t}\n\t\tfor (int i = 0; i < step; ++i)\n\t\t{\n\t\t\tif(x>=0 and x<R and y>=0 and y<C)sol.push_back(vector<int>{x,y}),n++;\n\t\t\tx--;\n\t\t}\n\t\tstep++;\n\n\n\n\t}\n        \n        return sol;\n        \n    }\n};\n\n```
[]