题目:
A. BerOS file system
题意:出现多个‘/’的时候,只留下一个‘/’,考察字符串的删除
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define LL long long
using namespace std;
string s;
void solve(string &s)
{
string::iterator it;
for (it=s.begin(); it<s.end(); it++)
{
if (it!=s.end()-1)
{
if ((*it)=='/'&&(*(it+1))=='/')
{
s.erase(it);
it--;
}
}
else
{
if (it>s.begin())
{
if ((*it)=='/')
{
s.erase(it);
}
}
else;
}
}
}
int main()
{
cin>>s;
solve(s);
cout<<s;
}