这里 string s; cin>>s; cout<<s<<endl; cin在读到空格时就停止读取,所以, 输入 asdf fghj 输出 asdf 若要保留空格,就需要用到getline getline(cin, s); 此时在enter前的空格都能读到。