fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. //write your code here
  7. int t;
  8. cin>>t;
  9. while (t--){
  10. int n;
  11. cin>>n;
  12. char arr[n];
  13. int count=0;
  14. for(int i=0;i<n;i++){
  15. cin>>arr[i];
  16. }
  17. for(int i=0;i<n;i++){
  18. if(arr[i]=='x'){
  19. count++;
  20. }
  21. }
  22. cout<<count<<endl;
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5284KB
stdin
2
4
a b c d
5
a b x c d
stdout
0
1