2026-11-15 20:37:02
发布于:浙江
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
getline(cin, s);
int pos = 0;
int need = 1; // 这一轮需要连续 need 个空格
while (true) {
string sp(need, ' ');
size_t p = s.find(sp, pos);
if (p == string::npos) {
// 找不到分割串,输出剩余部分
cout << s.substr(pos) << endl;
break;
}
// 输出这一刀的左边
cout << s.substr(pos, p - pos) << endl;
// 下一轮从这串空格之后开始
pos = p + need;
need++;
}
return 0;
}
这里空空如也














有帮助,赞一个