【Ybtoj 第6章 例题2】移位包含【字符串】

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


解题思路
字符串暴力即可。。。


代码

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;

string a,b,c;

int main(){
    
    
	cin>>a>>b;
	for(int i=0;i<a.size();i++)
	{
    
    
		if(a.find(b)!=-1)
		{
    
    
			printf("true");
			return 0;
		}
		c=a.substr(0,1);//返回从a下标0起的一个字符
		a.erase(0,1);//删除从a下标0起的一个字符
		a+=c;//在a字符串后加入c
	}
	printf("false");
}

猜你喜欢

转载自blog.csdn.net/kejin2019/article/details/113141328
今日推荐