#include<iostream> using namespace std; int main(){ string s; while(cin>>s){ cout<<s<<' '; } return 0; } 简单粗暴,利用cin不能读入空格不断流入,每次后面补上一个空格结束。