Problems in Nankai district (3)

Source: Internet
Author: User

Question requirements: for example, if the large string asasd asa small string as is n = 3, the answer is as follows: This is not difficult to understand, so no comments are added. [Cpp] nt findStr (char * str, char * substr) {char * p = str, * q = substr, * tem1 = NULL, * tem2 = NULL; int slen = strlen (str), sublen = strlen (substr); int count = 0; while (p-str <slen) {tem1 = p; tem2 = q; while (* tem1 = * tem2 & tem2-substr <sublen) {tem1 ++; tem2 ++; if (tem2-substr = sublen) {count ++; break ;}} p ++;} return count;} use an array to implement int findStr (char * str, char * substr) {int I = 0, j = 0; int tem1 = I, tem2 = j; int count = 0; While (str [I]! = '\ 0') {tem1 = I; tem2 = j; while (str [tem1] = substr [tem2] & substr [tem2]! = '\ 0') {www.2cto.com tem1 ++; tem2 ++; if (substr [tem2] =' \ 0') {count ++; break ;}} I ++;} return count ;}

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.