实现一个z字形的字符串排列
class Solution {
public:
void convert(string s) {
int n=s.size()-1, N = s.size() - 1;
int m = n % 4;
while (n>=0)
{
if (n != N)
{
cout << " ";
}
cout << s[N - n];
n -= 4;
}
cout << endl;
n = s.size() - 2;
while (n>=0)
{
if (n != N - 1)
{
cout << " ";
}
cout << s[N - n];
n -= 2;
}
cout << endl;
n = s.size() - 3;
while (n>=0)
{
if (n != N - 2)
{
cout << " ";
}
cout << s[N - n];
n -= 4;
}
}
};
int main()
{
Solution().convert("nihaowoshiyige");
return 0;
}
标签:12,cout,int,练习,打卡,size
From: https://www.cnblogs.com/wlxdaydayup/p/17400000.html