Hangzhou Electric---2087 cut the flower cloth

Source: Internet
Author: User

Problem Description

A piece of flower cloth, there are some patterns, there is a directly available small bar, there are some patterns. For a given strip of flowers and strips, calculate how many pieces of strips can be cut from the flower cloth?

Input

The input contains some data, respectively, is a pair of flowers and small strips, the cloth is shown with visible ASCII characters, the number of visible ASCII characters, the pattern of the cloth is also how many kinds of patterns. The strips and strips are not more than 1000 characters in length. If you meet the # character, you are no longer working.

Output

Output can be cut from the pattern cloth up to the number of small strips, if not a piece, then honestly output 0, each result should be wrapped.

Sample Input

ABCDE A3

AAAAAA AA

#

Sample Output

0

3

Author

Qianneng

Source

The second of Sanjiu in winter practice

Recommend

Lcy

Analysis: The problem is to find a string of problems, for example: AAAAAA AA is in the aaaaaa inside looking for a string of a, can find the words to remember once, the total number of strings, here to use a string function strstr () function, P=strstr (A, B), is in a inside looking for If you find it, you can assign a value to p for the first address.

#include <iostream> #include <stdio.h> #include <string.h>using namespace Std;int main () {    char a[ +];    Char b[1000];    while (Cin>>a)    {        if (a[0]== ' # ') break            ;        cin>>b;        int Lenb=strlen (b);        char *p=null;        int count=0;        P=a;        while (P=strstr (p,b))        //If it can be found that is counted into the loop, count++ once        {                count++;                P=p+lenb;          Update p look for next position        }            printf ("%d\n", count);    }    return 0;}


Hangzhou Electric---2087 cut the flower cloth

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.