编程之美中判断某个字符串是不是是另一个字符串的移位结构的子串
编程之美中判断某个字符串是否是另一个字符串的移位结构的子串
#include<iostream> #include<string> using namespace std; bool is_circle(string src,string des) { if(src.empty()||des.empty()) return false; string temp=src; temp+=src; string::size_type pos=0; pos=temp.find(des); if(pos==string::npos) return false; return true; } int main() { string src("AABCD"); string des("CDAA"); cout<<is_circle(src,des)<<endl; system("pause"); return 0; }