Searching SER7
QUESTION DESCRIPTION
Kanna is extremely disappointed to find out that no one in his school 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.
Kanna has 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 testcases, 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.
Kanna is extremely disappointed to find out that no one in his school 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.
Kanna has 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 testcases, 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
INPUT
5
SUVOJITSUVOSUVOJITUCSUVOJITSUVOVXSUVOJITSUVOGMSUVODMMVDSUVOJIT
AXRSUVOJITHSUVOJITHSUVOJJSUVOJITSUVOJIT
SUVOJITPRQSUVOJIT
SUVOJITTXGSUVOUNSUVOJIT
SUVOJITSUVOSUVOJITXGSUVOSUVOQSUVOJITKDSALASUOUSUVOJITGJEM
OUTPUTSUVO = 4, SUVOJIT = 5
SUVO = 1, SUVOJIT = 4
SUVO = 0, SUVOJIT = 2
SUVO = 1, SUVOJIT = 2
SUVO = 3, SUVOJIT = 4
#include <iostream>
#include<string>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
string arr;
cin>>arr;
//cout<<arr;
//cout<<arr.length();
int s=0,sj=0;
for(int i=0;i<=arr.length();i++){
if(arr.substr(i,4)=="SUVO"){
s++;
// cout<<i<<" "<<i+4<<"\n";
}
if(arr.substr(i,7)=="SUVOJIT")
sj++;
}
//cout<<arr.substr(4,4);
cout<<"SUVO = "<<s-sj<<", SUVOJIT = "<<sj<<"\n";
}
return 0;
}
Comments
Post a Comment