找规律
class Solution {
public:
string convert(string s, int numRows) {
string result = "";
if(numRows == 1)
{
return s;
}
int temp = 2*numRows-2;
for(int i = 0 ; i < numRows; i++)
{
if(i == 0 || i == numRows - 1)
{
for(int j = i; j < s.length(); j += temp)
{
result += s[j];
}
}
else
{
for(int x = i, y = temp - i; x < s.length() || y < s.length(); x += temp, y += temp)
{
if(x < s.length())
{
result += s[x];
}
if(y < s.length())
{
result += s[y];
}
}
}
}
return result;
}
};