请写出代码。旋转字符串:"waterbottle"是"erbottlewat"的旋转字符串。
简答题:
#include <iostream> #include <string> bool isSubstring(const std::string& vSource, const std::string& vSubStr) { if (vSource.find(vSubStr) != std::string::npos) return true; return false; } bool isRotate(const std::string& vLeft, const std::string& vRight) { if (vLeft.length() != vRight.length()) return false; return (vLeft+vLeft, vRight); } int main() { std::cout << isRotate("dayup", "upday") << std::endl; return 0; }
原文地址:http://blog.csdn.net/xiaoliangsky/article/details/38648829