c语言链表实现祖玛,Tsinghua OJ 数据结构编程作业:祖玛(Zuma)

提示

列表

#1 使用STL list

题目已提示使用list,首先贴上使用STL的代码,由于Tsinghua OJ上禁掉了大部分STL,所以只测试了样例中的数据。

#include

#include

#include

using namespace std;

#define N 20001

list l('#');

char s[N];

void del( list::iterator in, char c){

int sum = 0;

list::iterator first, second = in;

-- in;

first = in;

for (; first != l.begin(); -- first ) {

if (*first == c) {

sum ++;

}

else break;

}

for (; second != l.end(); ++ second) {

if (*second == c && c != '\0') {

sum ++;

}

else break;

}

if (sum >= 3) {

l.erase(++first, second);

del(second, *second);

}

}

int main(){

scanf("%s",&*s);

int len = (int)strlen(s);

for (int i = len-1; i >=0 ; i --) {

l.push_front(s[i]);

}

l.push_front('#');

int n;

scanf("%d",&n);

for (int i = 0; i < n; i ++) {

int ind;

char c;

scanf("%d %c",&ind,&c);

list::iterator in = ++l.begin();

for

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值