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