Advertisement
Anik_Akash

Code cef no 2

Jun 7th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int t, n, l;
  7.     char s[300001];
  8.     scanf("%d",&t);
  9.     while(t--){
  10.         scanf("%s",&s);
  11.         int x=0, y = 0;
  12.         l = strlen(s);
  13.         for(int i=0; i<l; i+=1){
  14.             if((s[i]==120)&& (s[i+1]==121)) x++;
  15.             else if((s[i]==121)&& (s[i+1]==120)) x++;
  16.         }
  17.         if(x>0)printf("%d\n",x);
  18.         else printf("0\n");
  19.     }
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement