对于一个字符串来说,定义一次循环移位操作为:将字符串的第一个字符移动到末尾形成新的字符串。
给定两个字符串s1和s2,要求判定其中一个字符串是否是另一个字符串通过若干次循环移位后的新字符串的子串。例如CDAA是由AABCD两次移位后产生的新串BCDAA的子串,而ABCD与ACBD则不能通过多次移位来得到其中一个字符串是新串的子串。
#include <iostream>
______(1)_______
using namespace std;
int main()
{
const int N=61;
char s1[N],s2[N],x[N],t[N];
int l1,l2;
_____(2)_______
if(strlen(s1)<strlen(s2))
{
strcpy(t,s1);
______(3)_____
strcpy(s2,t);
}
strcpy(x,s1);
if(strstr(_____(4)__,s2)==NULL)
cout<<"false\n";
else
cout<<"true\n";
return 0;
}