STL 水题 Fixing Typos(string 容器)
2013-11-14 15:54
225 查看
题目连接 http://codeforces.com/problemset/problem/363/C
//string容器
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
char str[210000];
int main()
{
int f1,f2,i;
string s;
while(gets(str))
{
s=str;
f1=0;
string::iterator it=s.begin();
for(;it!=s.end();it++)
{
if(f1&&*it==*(it+1))//例如:hhggggghh 则x=4 删除后:hhghh
{
int x;
x=1;
while(*it==*(it+x))
x++;
s.erase(it+1,it+x);
}
f1=0;
if(*it==*(it+1))//例如:hhhhhhhhhhgghhh 则x=8 删除后:hhgghhh
{
int x;
f1=1;
if(*it==*(it+2))
{
x=2;
while(*it==*(it+x))
x++;
s.erase(it+2,it+x);
}
it++;
}
}
cout<<s<<endl;
}
return 0;
}
//string容器
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
char str[210000];
int main()
{
int f1,f2,i;
string s;
while(gets(str))
{
s=str;
f1=0;
string::iterator it=s.begin();
for(;it!=s.end();it++)
{
if(f1&&*it==*(it+1))//例如:hhggggghh 则x=4 删除后:hhghh
{
int x;
x=1;
while(*it==*(it+x))
x++;
s.erase(it+1,it+x);
}
f1=0;
if(*it==*(it+1))//例如:hhhhhhhhhhgghhh 则x=8 删除后:hhgghhh
{
int x;
f1=1;
if(*it==*(it+2))
{
x=2;
while(*it==*(it+x))
x++;
s.erase(it+2,it+x);
}
it++;
}
}
cout<<s<<endl;
}
return 0;
}
相关文章推荐
- 一个简单的游戏开发框架(三.事件管理)
- CleanMyMac2清理 lanchpad里面的图标没了
- php函数大全
- IE打印 WebBrowser.ExecWB的完整说明
- 高级分组
- 集合操作
- 秉承六大经营原则扎根网络游戏行业
- ubuntu下配置GLUT+CodeBlocks
- 酷壳 – CoolShell.cn
- ejabberd
- Python学习要点和陷阱
- leetcode: Median of Two Sorted Arrays
- 在LATEX里面修改算法名字
- java线程优先级的简单应用
- IE6 div最小高度去除方法以及IE6div垂直居中css样式
- 聚集,分组,行转列
- VIM个性化配置_折叠设置
- 网站运营推广:网站取名与做好定位很关健
- uva 331 Mapping the Swaps
- AFNetworking