classSolution{public:
string convert(string s,int numRows){if(numRows==1){return s;}
string ret;int d =2* numRows -2;//第0行
size_t i =0, n = s.size();while(i < n){
ret += s[i];
i += d;}//第1-n-2行for(int i =1; i < numRows-1; i++){int k = i;int m = d - i;while((k < n)||(m < n)){if(k < n){
ret += s[k];
k += d;}if(m < n){
ret += s[m];
m += d;}}}//第n-1行
i = numRows -1;while(i < n){
ret += s[i];
i += d;}return ret;}};