```
class Solution {
public:
string convert(string s, int numRows) {
if (numRows == 1 || s.length() <= numRows) return s;
string res;
for (int i = 0; i < numRows; ++i)
{
for (int j = 0; i+j*2*(numRows-1) < s.length(); ++j)
{
res += s[i+j*2*(numRows-1)];
if (i != 0 && i != numRows-1 && i+2*(numRows-i-1)+j*2*(numRows-1) < s.length()) res += s[i+2*(numRows-i-1)+j*2*(numRows-1)];
}
}
return res;
}
};
```