MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

CodeChef_problems/Chef and String/solution.cpp:3–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include<iostream>
2using namespace std;
3int main()
4{
5 int t;
6 cin>>t; //Input of number of testcases
7 while(t--)
8 {
9 string s;
10 cin>>s; //Input of a String containing x or y letters
11 int i,c=0;
12 //Calculating the maximum numbers of pairs formed
13 for(i=0;i<s.length();i++)
14 {
15 if((s[i]=='x'&&s[i+1]=='y')||(s[i]=='y'&&s[i+1]=='x'))
16 {
17 c++; //If y letter is the next element of x or x letter is the next element of y then we increase the c by 1
18 i++;
19 }
20 }
21 cout<<c<<endl; //printing the maximum number of pairs
22
23 }
24 return 0;
25
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected