fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin>>t;
  7. for(int c=0;c<t;c++){
  8. string s;
  9. cin>>s;
  10. int n=s.length();
  11. int tot=0;
  12. bool yet=0;
  13. int curr=0;
  14. for(int i=0;i<n;i++){
  15. if(s[i]=='0' and yet){
  16. tot++;
  17. curr++;
  18. }
  19. else{
  20. curr=0;
  21. yet=1;
  22. }
  23. }
  24.  
  25.  
  26. cout<<tot-curr<<"\n";
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 4404KB
stdin
3
010011
00
1111000
stdout
2
0
0