思路:这个巧妙之处在于:cin可以自动过滤掉空格,然后每读入一个字符,输出一个空格
#include<iostream> using namespace std; int main(){ string a; while(cin>>a) cout<<a<<' '; return 0; }