substr 与 substring(CodeForces - 977B Two-gram)

本文介绍了C++中substr和substring两种字符串截取方法的使用,包括参数含义和注意事项,并结合CodeForces 977B Two-gram问题,讲解如何找出字符串中出现最频繁的连续两个字符(two-gram)。
摘要由CSDN通过智能技术生成

substr 与 substring

         均是截取字符串长度;

均在头文件  <string> 中 包含;

substr(start,length);

start 表示起始的位置,length表示需要的长度

返回为 从 start开始,往后的length个元素,

若不写length 则 从start开始到结束

若length <= 0 则 s.substr(start, length) == NULL;

substring(start,end);

start 表示起始位置,end表示末尾位置

Two - gram:

题目:

Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, "AZ", "AA", "ZA" — three distinct two-grams.

You are given a string ss consisting of nn capital Latin letters. Your task is to find any two-gram contained in the given string as a substring (i.e. two consecutive characters of

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值