字符串移位包含問題

在這裏插入圖片描述

#include<bits/stdc++.h>
using namespace std;
int fun(string s,string t)
{
	int len=s.length();
	while(len--)
	{
		if(s.find(t)!=string::npos)
			return 1;
		s.push_back(s[0]);
		s.erase(s.begin());
	}
	return 0;
}
int main()
{
	string a,b;
	cin>>a>>b;
	if(fun(a,b)||fun(b,a))	cout<<"true";
	else	cout<<"false";
}
	
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章