007 string, string
If you have an isSubstring function, you can check whether a string is a substring of another string.
The s1 and s2 strings are provided. Only one isSubstring is used to determine whether s2 is a s1 rotating string,
Write the code. Rotating string: "waterbottle" is the rotating string of "erbottlewat.
Short answer:
#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;}
Why is the string constant "\ 007" invalid?
\ 0 is the string Terminator, \ is the Escape Character, \ remove or write \\
The slash '\' and the string "\ 007" are valid constants.
Invalid
It is legal to change '\' '\'.
Changed "\ 007" to '\ 007' legal
Meaning of escape characters
\ N carriage return line feed
\ T jump horizontally to the next tabulation position
\ Backslash \
\ 'Single quote'
\ "Double quotation mark"
\ Ddd 1 ~ Three octal characters
\ Xhh 1 ~ 2-digit hexadecimal number