删除 string s,a; s="123456"; cout<<a; while(s.find(' ')!=false) //如果在s中找到,就执行 { s.erase(find(s.begin(),s.end(),' '));//每次删除一个 } cout<<s<<endl;