标签:include size iostream space etl bsp flag lin clu
#include <iostream>
using namespace std;
#include <string>
// hello world ->world hello
int main()
{
string s, s1, s2;
int flag = 0, i = 0;
getline(cin, s);
for (int j = 0; j < s.size(); j++) {
if (s.at(j) == ‘ ‘) {
s1 = s.substr(flag, j - flag);
if (i == 0) {
s2 = s1;
i++;
}
else
s2 = s1 + " " + s2;
flag = j + 1;
}
if (j == s.size() - 1) {
s1 = s.substr(flag, j - flag + 1);
s2 = s1 + " " + s2;
}
}
cout << s2;
return 0;
}
标签:include size iostream space etl bsp flag lin clu
原文地址:https://www.cnblogs.com/xufeng123/p/12628857.html