C++编程
从键盘输入一个字符串,删除字符串中的所有空格后输出这个字符串。(C++)
2018-11-06 23:28
程序代码:#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
string s;
// 输入一行
getline( cin, s );
// 删除空格
s.erase( remove(s.begin(),s.end(),' '), s.end() );
// 输出
cout << s << endl;
}
2018-11-07 08:42
2018-11-07 17:55
2018-11-07 21:04