Where is 1346 pig?

Source: Internet
Author: User
Description

Mr. l received an uncertain email yesterday, which contains a string of letters, all lowercase letters. I was about to throw it, and I suddenly received a text message: Please check the three letters starting with the letter in * line. At first glance, it's "pig". MR. L is going crazy, because he hates people talking about this word most, so he decided to find out how many "pig" in this text "......

Input

The first line of input data is T, indicating that T groups of data exist.

Each row contains a group of data, each containing an integer N and a letter containing n characters.

(N <= 2000)

There is a space between an integer and an array of characters, all of which are lowercase letters.

Output

For each group of data, output a line containing an integer to indicate the number of pig records found in this letter ".

 

 

Simple question search

# Include <stdio. h> main () {int number, Te; char s [2000]; int num; int I; int count; scanf ("% d", & number ); for (TE = 1; te <= number; Te ++) {COUNT = 0; scanf ("% d % s", & num, & S ); for (I = 0; I <= num-2; I ++) {If (s [I] = 'P' & S [I + 1] = 'I' & S [I + 2] = 'G ') count ++;} printf ("% d \ n", 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.