fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. long long findLastIndex(string& str, char x)
  6. {
  7. long long index = -1;
  8. for (int i = 1; i <=str.length(); i++)
  9. if (str[i] == x)
  10. index = i;
  11. return index;
  12. }
  13.  
  14.  
  15. int main()
  16. {
  17.  
  18. string str;
  19. getline(cin,str);
  20.  
  21.  
  22. char x = '0';
  23. long long index = findLastIndex(str, x);
  24. if (index == -1)
  25. cout << "0";
  26. else
  27. cout << index+1;
  28. return 0;
  29. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
Standard output is empty