算法基礎之旋轉詞17

題目:如果一個字符串str,把字符串str前面任意的部分挪到後面形成的字符串叫做str的旋轉詞。

#include<iostream>
using namespace std;
int main()
{
	string str1,str2;
	cin>>str1>>str2;
	str1+=str1;
	if(str1.find(str2)!=string::npos)
		cout<<true;
	else
		cout<<false;
	return 0;
}

通過將字符串重複拼接在通過查找算法判斷是否是旋轉詞

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章