Question Name:Searching 2

#include <stdio.h>

int main()
{
int TestCases=0;
//scan testcases
scanf("%d",&TestCases);
while(TestCases)
{
char text[101];
int countSUVO=0;
int countSUVOJIT=0;
int i;
//scan text
scanf("%s",text);
for( i=0; text[i]!='\0';i++)
{
if(text[i]=='S' && text[i+1]=='U' && text[i+2]=='V' && text[i+3]=='O')
{
if(text[i+4]=='J' && text[i+5]=='I' && text[i+6]=='T')
{
countSUVOJIT++;
i=i+6;
}
else
{
countSUVO++;
i=i+3;
}
}
}
printf("SUVO = %d, SUVOJIT = %d\n",countSUVO,countSUVOJIT);
TestCases--;
}
return 0;
}

Problem Description

Manna is extremely disappointed to find out that no one in his college knows his first name. Even his classmates call him only by his last name. Frustrated, he decides to make his fellow college students know his first name by forcing them to solve this question.

You are given a long string as input in each testcase, containing any ASCII character. Your task is to find out the number of times SUVO and SUVOJIT appears in it.

Input Format
The first line contains the number of test cases, T. Next, T lines follow each containing a long string S.

Output Format
For each long string S, display the no. of times SUVO and SUVOJIT appears in it.

 

  • Test Case 1

    Input (stdin)

    5
    SUVOJITSUVOSUVOJITUCSUVOJITSUVOVXSUVOJITSUVOGMSUVODMMVDSUVOJIT
    AXRSUVOJITHSUVOJITHSUVOJJSUVOJITSUVOJIT
    SUVOJITPRQSUVOJIT
    SUVOJITTXGSUVOUNSUVOJIT
    SUVOJITSUVOSUVOJITXGSUVOSUVOQSUVOJITKDSALASUVOQESUVOHSSUVODFSUVOJITWSUVOUSUVOJITGJEM
    

    Expected Output

    SUVO = 4, SUVOJIT = 5
    SUVO = 1, SUVOJIT = 4
    SUVO = 0, SUVOJIT = 2
    SUVO = 1, SUVOJIT = 2
    SUVO = 7, SUVOJIT = 5
  • Test Case 2

    Input (stdin)

    3
    SUVOJITSU
    651SUVOMN
    $$$$$SUVOSUVOJIT$$$$$
    

    Expected Output

    SUVO = 0, SUVOJIT = 1
    SUVO = 1, SUVOJIT = 0
    SUVO = 1, SUVOJIT = 1

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.