You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
470 B

#include <iostream>
using namespace std;
//双指针算法
// 输入样例 abc def ghi
int main() {
string str;
getline(cin,str); //注意这里输入带空格字符串的方法
int n = str.length();
// 模板是用来节约思考的时间
for (int i = 0; i < n; i++) {
int j = i;
while (j < n && str[j] != ' ') j++;
for (int k = i; k < j; k++) cout << str[k];
cout << endl;
i = j;
}
return 0;
}