007 string, string

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.