fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.  
  5. int t;
  6.  
  7. cin >> t;
  8. while (t--) {
  9. string s;
  10. cin >> s;
  11. int x;
  12. for (int i = s.size() - 1; i >= 0; i--) {
  13.  
  14. if (s[i] != '0') {
  15. x= i;
  16. break;
  17. }
  18. }
  19. int c = 1;
  20. for (int i = 0; i < x; i++) {
  21.  
  22. if (s[i] == '0')c++;
  23.  
  24. }
  25.  
  26. cout << s.size() - c << endl;
  27.  
  28. }
  29.  
  30. }
  31.  
  32.  
Success #stdin #stdout 0.01s 5288KB
stdin
4
666
13700
102030
7
stdout
2
4
3
0