解题思路:用STL的erase来删除空格
注意事项:
参考代码:
#include <deque>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <iterator>
#include <numeric>
#include <string>
#include <string.h>
using namespace std;
int main()
{
int k=0;
deque<string> q;
string str;
while(getline(cin,str))
{
for(int i=0;i<str.size();i++)
{
if(str[i]==' ')
{
str.erase(str.begin()+i,str.begin()+i+1);
}
}
q.push_back(str);
}
copy(q.begin(),q.end(),ostream_iterator<string>(cout,"\n"));
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:628 |
简单的a+b (C语言代码)浏览:494 |
P1001 (C语言代码)浏览:801 |
C语言训练-尼科彻斯定理 (C语言代码)浏览:469 |
母牛的故事 (C语言代码)浏览:945 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:558 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:587 |
剪刀石头布 (C语言代码)浏览:1436 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:564 |
1073题解浏览:624 |