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 );}}