Wuhan University of Science and Technology acm:1007: text editor

Source: Internet
Author: User

Problem Description

YB intends to write a powerful text editor, and take a cool pull wind, high-end elegant name, such as "YB brand text editor" and the like. Since it is powerful, there must be a search function. But he had a little problem when he finished the function. Now come and ask for your help.

To give you a text string s and a pattern string t, you need to write a program to find out how many times T has appeared in S.

Input

The first line is a positive integer t, which indicates that there is a total of T-Group test data.

There is a T-group test followed by two rows per set of test data. The first line is the text string s, and the length is not greater than 10000. The second line is the pattern string T, which is not longer than 10. is a string of lowercase letters only.

Output

Each set of tests corresponds to the output of a positive integer answer, indicating how many times K appears in S.

Sample Input
2abababaabaabcabcabc
Sample Output
32
HINT
1#include <stdio.h>2#include <string.h>3 intStrstrcount (Char*STR1,Char*str2)4 {5     Char*str =str1;6Unsignedintc =0;7     8      while(str = strstr (str, str2))! =NULL)9     {TenC++; Onestr++; A     } -     returnC; - } the  - intMain () - { -     Chara[10001],b[ One];  +     inti,j,c; -     intN; +     intresult; Ascanf"%d",&n); at      while(n--) -     { -scanf"%s%s",&a,&b); -         { -result=Strstrcount (A, b); -printf"%d\n", result); in         } -     } to  +     return 1; -}

Wuhan University of Science and Technology acm:1007: text editor

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.